• Home
  • LinuxBashFiles
  • Batch Remove spaces from filenames, and convert upper case to lowercase via bash

Batch Remove spaces from filenames, and convert upper case to lowercase via bash

Use the following script:

#!/bin/bash

ls | while read -r FILE
do
    mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'`
done