How to make all file names in a directory a uniform format/file name uniform script

Using this basic Perl script, you can preform the task quickly.

It is set to change only video or audio files of type
 * ("avi","rm","mpg","mpeg","asf","ram","wmv","mp4","ogg","m4v","rmvb","mp3"."wav","mp2","au","ram","wma")
 * You can add more file types as you wish
 * To process all file types, set
 * $disableExt = 1;

The $commanRemoval variable, is used to remove some common tags added to file. Please add more is you know any. Don't forget the escape charator, \, when using periods, etc.

The script:
 * 1) !/usr/bin/perl -w

$test = 0; $disableExt = 0;
 * 1) Config

@fileExt = ("avi","rm","mpg","mpeg","asf","ram","wmv","mp4","ogg","m4v","rmvb","mp3"."wav","mp2","au","ram","wma");

@commonRemoval = ('YG_DivX4s','DivX_TV','divx-svm','xvid-stfu','xvid-aaf','xvid-fov','xvid-sfm','xvid-xor','xvid-river','xvid-angelic','xvid-0tv','xvid-2hd','hdtv-xor','HDTV-CTU','PROPER_hdtv','hdtv-2HD','HDTV-YESTV','HDTV-CTU','HDTV-AAF','HDTV-BIA','PDTV-RIVER','HDTV-FQM','HDTV-LOL','PDTV-ANGELIC','PDTV-SAINTS','DSRIP-0TV','DSRIP-0TV','divx','xvid','digitaldistractions','www\.mrtwig\.net','irc\.tveps\.net','www\.southparkx\.net','fqm\.sharconnector','spepisode','Videoseed\.com','iPodNova\.net','iPodNova\.tv','iPodTVNova\.com','Videoseed_com','iPodNova_net','ipodnova_tv','dsr_lol','avi_sm','spcomplete_com','dsr_umd','ipod_mpg4','ipod_mpg','dsr_loki','\{C_P\}','dsrip-stfu','pdtv-lol','DVDRip','dvdrip','dsrip','HQTV','HDTV','PDTV','YesTV','TVrip','ac3','-sfm-','NiteShdw','\[fixed\]','\[VTV\]','\[bt\]','\[tvm\]','\[vpc\]','\{C_P\}','\(1\)','\(iPod\)','x264','h264','[0-9][0-9][0-9]kbps');

if($ARGV[0] eq ""){ print "the first arg is the directory\n"; exit; }

sub isVideo { #if I wanted to only do videos # doo my $filename = $_[0]; foreach $ext (@fileExt) { if ($filename =~ /$ext$/i) { return 1; } else { }	}	0; } sub renamer { my $oldname = $_[0]; $oldname =~ tr/A-Z/a-z/; foreach $removal (@commonRemoval) { $oldname =~ s/($removal)/_/i; }
 * 1) 			print "$ext: $filename: match\n";
 * 1) 			print "$ext: $filename: no match\n";


 * 1) 	$outname =~ s/\.([a-z]{2,4})$/\1/;

$oldname =~ s/[_\!\[\]\(\)\.\s]/_/g;


 * 1) 	$oldname =~ s/s0([0-9])e([0-9]{2})/_\1\2_/;
 * 2) 	$oldname =~ s/_([0-9]{1,2})x([0-9]{2})_/_\1\2_/;
 * 3) 	$oldname =~ s/s([0-9]{2})_e([0-9]{2})/_\1\2_/;
 * 4) 	$oldname =~ s/s([0-9]{2})e([0-9]{2})/_\1\2_/;
 * 5) 	$oldname =~ s/^([0-9])/south_park_\1/;

for ($x=0;$x<=$#findit;$x++){ $oldname =~ s/@findit($x)/@replaceit($x)_/i; print "peep-"; }


 * 1) 	$oldname =~ s/southpark/south_park/;
 * 2) 	$oldname =~ s/south_park([0-9])/south_park_\1/;

$oldname =~ s/_+/_/g; $oldname =~ s/_-_/-/g; $oldname =~ s/^_//; $oldname; }

sub reext { my $fname = $_[0]; $fname =~ s/_([a-z0-9]{2,4})$/\.\1/; $fname; }

print "starting processes....\n";

opendir(DIR, "$ARGV[0]");

while (defined($dir = readdir(DIR))) { if ( isVideo($dir) || $disableExt ) { 	print "---$dir\n"; $newname = renamer($dir); $newnewname = reext($newname); print "\n\nMoving:\nA: $dir\nB: $newnewname\n\n"; if(!$test) { system("mv \"$ARGV[0]/$dir\" \"$ARGV[0]/$newnewname\""); } } else { print "not a know extension no...\n"; }	}
 * 1) 	print "$dir";

closedir(DIR); print "done...\n\n";