#!/bin/sh # bourne shell script by Julian Stacey # Move horrid Microsoft file or directory with spaces in name to a # Unix friendly name with underscores. # How to use it: # find . -name \*' '\* -exec ~/bin/.sh/despace {} \; # Warning: # - Might blow on a name with a ` or ' # - I dont bother to check if this will trash another pre existing file # - It wont deal with a file that has space at beginning or end of name, # only those with one or more spaces in the middle. mv "$1" "`dirname \"$1\"`"/`basename "$1" | tr "\ " "_"` # test: # mkdir "aa aa" ; touch "aa aa/bb bb" # find . ; find . -depth -exec despace {} \; ; find . # See Also (& run after): ~/bin/.sh/tolower