Let's say you have a bunch of Audio files that you have ripped from the CD or bought online or recorded own your own. Normally these file names are in the proper case with spaces separating the words e.g. Jamba Music.mp3 or Till You Live.mp3 etc.

This is better for readability but not optimized for posting on the website. So converting these filenames to lowercase with hyphen separated manually is not easy since there can be hundreds or more of such files. The following Perl script can do the job faster and easier. This script can be run from Unix/Linux or Cygwin (Windows) terminal in the directory where the files are stored. So go to the directory where your audio files are stored and then follow these steps.

Copy this script into any file and name it perl_rename.sh

# Usage: rename perlexpr [files]

($regexp = shift @ARGV) || die "Usage:  rename perlexpr [filenames]n";

if (!@ARGV) {
   @ARGV = <STDIN>;

foreach $_ (@ARGV) {
   $old_name = $_;
   eval $regexp;
   die $@ if $@;
   rename($old_name, $_) unless $old_name eq $_;


Copy the following in another file , say named fix_case.sh

./perl_rename.sh 'y/A-Z/a-z/' *

And finally copy the following in another file , say named fix_name.sh

./perl_rename.sh  's/ /-/g' *

Now make sure you can execute all these files by changing the permissions as:

chmod +x *.sh

Ex. your directory consists of the following files whose names need to be updated.

Jamba Music.mp3

Till You Live.mp3

Bon Jon Rock.mp3

Now run these 2 Scripts one after the other. The order in you run does not matter, the end result is the same.



Check your directory and you should see.




All these files are converted to lower case, with space replaced with hyphens. Upload these files to your web server and you are done.