Solve problems with filenames/dirnames with trailing whitespace