Ok, here's a version that actually works!
#!/usr/bin/python
import glob
import re
import sys
import os
if len(sys.argv) != 3:
[tab]print "USAGE: renamer old_pattern new_pattern"
[tab]sys.exit()
files = glob.glob('*' + sys.argv[1] + '*')
for file in files:
[tab]new_file = re.sub(sys.argv[1], sys.argv[2], file)
[tab]print file, "\t\t", new_file
[tab]os.rename(file, new_file)
I've only done some
very rudimentary testing. Don't blame me if it eats your data

Replace the
[tab] with an actual tab.
Here's what this code will do for you:
Say you have some files and directories in your local directory:
stuff.f stuffit.f more_stuff.c more_stuff.h dir_stuff
Call renamer like this: renamer stuff STUFF
now you have:
STUFF.f STUFFit.f more_STUFF.c more_STUFF.h dir_STUFF
Of course, it would be nice to have more control of the pattern matching That's left as an exercise for the reader
