Trim filenames before replacing spaces