How to replace spaces in file or directory names with hyphens or underscores with the Linux shell.

This command will take all files and directories in a folder and replace all of the spaces in their names with hyphens. This could be a very useful command when you want the files to have sensible filenames. john@adeptus-mechanicus ~ $ ls -hula | perl -e ‘rename $_, s/\s+/-/gr for (<*>)’john@adeptus-mechanicus ~ $ ls -hula … Read more