Compacted regular expression to fix filenames

This method should work better. The old one was allowing some unwanted
characters from getting through, such as periods in folder names, which
is fine for Linux but would not work properly in Windows. Try ending a
folder name with a period in Windows and it will not work.