Python File Renamer

import os
illegal = list('''!"#$%&'()*+,/:;<=>?@[\]^_`{|}~''')
repl = " "
for root,dir,files in os.walk(os.getcwd()):
    for fi in files:
       for ill in illegal:
            if ill in fi:
                print "found ",  os.path.join(root,fi)
                newname = fi.replace(ill,repl)
                os.rename( os.path.join(root,fi) , os.path.join(root,newname) )

Comments are closed.