Using bash Shell to Rename Files With Spaces

The following is a shell command that you can use to rename any file that contains spaces. Without the quotes surrounding the $file reference and the echo command it will fail.

In this example, we rename anything that is .htm to .html

for file in *.htm ; do mv “$file” “`echo “$file” | sed ‘s/\(.*\.\)htm/\1html/’`” ; doneContinue reading “Using bash Shell to Rename Files With Spaces”