I have written a small python script to remove all characters from filenames that makes handling them under *nix difficult.
Perhaps this can help you as well.
# -*- coding: UTF-8 -*-
usage: fixFileNames.py FILE...
Renames FILEs to sensible names, avoiding collision.
from string import maketrans
move file to filename:
- without spaces, pipe characters, quotes
intab = ' |'
outtab = '__'
trantab = maketrans(intab, outtab)
newFileName = file.translate(trantab, '\'\"').replace('_-_', '-')
if file != newFileName:
#only renames file if it's name contains any unwanted characters
print "ERROR: Not renaming %s, %s exists already" % (file, newFileName)
print "renaming %s to %s" % (file, newFileName)
# print "file %s and newFilename %s are equal" % (file, newFileName)
if __name__ == "__main__":
if not len(sys.argv) > 1:
for file in sys.argv[1:]:
Anyone is free to use and or improve this. If you have any improvements I'd like to hear about them.