fir3net
PPS-Firenetbanner-780.5x190-30-03-17

Bourne - File name Converter

This script will convert any mp3/wav/wma files into neat and tidy naming format,

#!/bin/sh

ls | /bin/egrep -i ".wma|.mp3|.wav" > /dev/null
if [ $? == 0 ]

then
   ls | /bin/egrep -i ".wma|.mp3|.wav"  | while read source
   do
             dest=$(echo "$source" | /bin/sed 's/^[0-9]*[-,_]//;s/^-//;s/\_/ /g;s/^ *//g;;s/.*/\L&/g;s/-/ - /g;s/  / /g;s/\<./\u&/g;s/...$/\L&/')
             /bin/mv -fv "$source" "$dest"
   done
   exit 0
else
   echo -e "\E[31mERROR : No music files found in `pwd`"; tput sgr0
fi

exit $?

When copying this script to your UNIX terminal, please copy it into a text editor first. This will prevent any special characters being copied across with the script. A good tool to check this is to run cat -e filename.sh within your UNIX shell, this will show you the text and any special characters.

A modified script for the above can also be found here.

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001