oh, quick and dirty ey ? find . -type d -iname '* *' -exec sh -c 'mv "$1" "${1// /_}"' -- {} \; find . -type f -iname '* *' -exec sh -c 'mv "$1" "${1// /_}"' -- {} \; No need for a script then :P Seriously, being correct is ALWAYS more important than being fast in the real world. If you learn the right way to write shell scripts, it WILL save time in the long run (whether it's a production machine or a desktop!). Trust me on this one. Anyway, at least learn how word splitting works and why it's there, it'll pay back quickly, i promise ;)