# nasty filenames can cause problems # belows is a modification of rajak's # quick and dirty renamer. Renames # spaces, ()'s, and "'"'s. foreach $xold ('ls'){ # chomp $xold; $xnew = $xold; $xn = $xold; # $xnew = lc($xn); ## lowercase it $xnew =~ s/\%20/_/g; ## Converts netscape screwup to a _ $xnew =~ s/\ /_/g; ## Converts space to a _ $xnew =~ s/\(/-/g; ## Removes ( and subs - $xnew =~ s/\)//g; ## Removes ) $xnew =~ s/\[/-/g; ## Removes [ and subs - $xnew =~ s/\]//g; ## Removes ] $xnew =~ s/\{/-/g; ## Removes { and subs - $xnew =~ s/\}//g; ## Removes } $xnew =~ s/\#//g; ## Removes # $xnew =~ s/\!//g; ## Removes ! $xnew =~ s/\~//g; ## Removes ~ $xnew =~ s/\'//g; ## Hickey remover $xnew =~ s/_-_/-/g; ## Shorten _-_ to - $xnew =~ s/-*-/-/g; ## Shorten 2 or more -- to 1 - $xnew =~ s/_*_/_/g; ## Shorten 2 or more __ to 1 _ $xnew =~ s/-_/-/g; ## Clean up -_ to - $xnew =~ s/\&/\+/g; ## Clean up & for eaiser use in unix $xnew =~ s/\,_/\+/g; ## Set up for format artist1+artist2 $xnew =~ s/_\+_/\+/g; ## Shorten _+_ to + $xnew =~ s/_-/-/g; ## Clean up _- to - $xnew =~ s/-\./\./g; ## Remove extra -'s infront of .mp3 $xnew =~ s/\.-/\./g; ## Remove extra -'s behind a dot $xnew =~ s/\._/\./g; ## Remove extra _'s behind a dot $xnew =~ s/^-//g; ## Remove - at beginning of filename $xnew =~ s/^_//g; ## Remove _ at beginning of filename $xnew =~ s/^\.//g; ## Unhide files if($xnew ne $xold){ print "Renaming $xold to $xnew\n"; rename $xold, $xnew or die "Failed renaming $xold\n"; } }