If you're in Linux, use:

# rename 'y/\ /_/' *



From: saidimu apale <saidimu@gmail.com>
To: Skunkworks forum <skunkworks@lists.my.co.ke>
Sent: Sat, November 21, 2009 2:20:49 AM
Subject: [Skunkworks] if you ever need to rename 100+ files...

I needed to quickly and painlessly rename some files by replacing spaces with underscores (_). Here's a quick and dirty python script that did it for me. I ran it from the python interpreter command-line (I didn't save the script to a file... lazy).

----- begin script-----
import os

for file in os.listdir(os.getcwd()):
     newname = "_".join(file.split())
     os.rename(file, newname)

----- end script------

It's a quick and dirty script so there's no error-handling of *any* sort. But that's trivial to add if you needed it.