Strip bad characters from directory names, as well as filenames