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 below:

#!/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/\<./\u&/g;s/...$/\L&/;s/+/ /g;s/([0-9]*)//g;s/^[0-3][0-9]//g;s/^ *//g;s/ ["."]/./g;s/--\|- -/-/g;s/[dD]on*e*l* /Donnell /g;s/[dD].*.*n*gelo/D`Angelo/g;s/[D][j]/DJ/g;s/Ll [cC]ool/LL Cool /g;s/-/ - /g;s/  / /g')
            /bin/mv -fv "$source" "$dest"
   done
   exit 0
else
   echo -e "\E[31mERROR : No music files found in `pwd`"; tput sgr0
fi

exit $?
Rick Donato