Snippet to remove caps and spaces from filename

Remove caps and spaces from names in files in current directory with tr command. First step is parse the name of the file or directory and then rename it.

for f in *; do
file=$(echo $f | tr A-Z a-z | tr ' ' _)
[ ! -f $file ] && mv "$f" $file
done


Posted

in

by

Tags: