More robust removal of the folder names