Monday, November 24, 2008

fixfiles.py - A python script to rename files

Tired of crazy filenames with lots of spaces, CAPS and other characters on your linux machine? Many *nix users transfer files from windows or mac computers where filenames with spaces and other characters included in them dont matter so much. Here in the linux world, some people care about the excessive use of escaping all those spaces when addressing those filenames.

I wrote a simple python script to help me fix this for myself. The script will rename files that contain uppercase, ampersand or spaces and convert them into characters a bit more friendly to you while managing your files on your linux machine. Here is an example of it in action:

$ fixfiles.py /home/nmaxwell/foo/
Renaming: foo/YaDDA YAdda YaddA to: foo/yadda__yadda_yadda__
Renaming: foo/File With CAPS & Stuff to: foo/file_with_caps_-and-_stuff
Renaming: foo/BaZ to: foo/baz
Renaming: foo/Bar to: foo/bar
Renaming: foo/fOO to: foo/foo

As shown, it just searches filenames in a given directory, and renames them to be a little friendlier for you by changing the characters to something easier to manage.

Download fixfiles.py

No comments:

Post a Comment