Remove Spaces from Filenames How can I eliminate spaces in all my filenames? This 'sh' shell script will do the trick, providing no two filenames in a directory differ by only spaces, and no directory names have spaces. % cat sh2 #!/bin/sh target_fn=$( echo $1 | tr -d " " ) if [ ! "$1" = "$target_fn" ]; then echo mv "$1" "$target_fn" mv "$1" "$target_fn" fi % ls -R1 .: dirname file name file2 name sh sh2 tsh dirname: file2 name file3name % find . -print0 | xargs -0 -n1 ./sh2 mv ./dirname/file2 name ./dirname/file2name mv ./file name ./filename mv ./file2 name ./file2name % ls -R1 .: dirname file2name filename sh sh2 tsh dirname: file2name file3name