#This will replace spaces with '_' in all files in directies, it can be modified as needed. find . -name '* *' -exec /bin/sh -c 'echo {} | (read f ; mv "$f" `echo "$f" | sed "s/ /_/g"`)' \; #same end result as above, but in a slighly simpler syntax for i in `find . -name '* *'`; do mv $i `echo $i |sed "s/ /_/g"` done