Rename All Filenames With Spaces to Underline

If you want to just rename a space to an underline in all filenames in a directory, try:

for fname in *; do mv "$fname" `echo $fname | tr ' ' '_'`; done