It changes all mp3 names in the specified dir (. per default). I'm tired of those odd file names mp3 have on the internet. It strips some chars that i dislike (spaces, commas, quotes) and make everything lower case. Many people that I know found it very useful. I hope you'll too. :) I really want you to comment if there's something wrong (style) or if there's a better way to do something. I'm learning perl. (Changed)
use String::ShellQuote use Cwd; unless ($ARGV[0]) { $dir = getcwd; } else { $dir = $ARGV[0]; } unless ($dir =~ /[\/]$/) { $dir .= "/"; } opendir (DIR, $dir) or die $!; my @arquivos = grep /\.mp3$/i, readdir DIR; foreach my $mp3file (@arquivos) { $new_name = $mp3file; $new_name =~ s/\s+/_/g; $new_name =~ s/_-_/-/g; $new_name =~ s/^[-_]+//; $new_name =~ s/&/and/g; # & becomes "and" $new_name =~ s/[\(\)\[\]]+/_/g; # () and [] become _ $new_name =~ s/,/_/g; $new_name =~ s/[\'\"]+/_/g; # no quotes $new_name =~ s/\`+/_/g; $new_name =~ s/_+/_/g; $new_name =~ s/-+/-/g; $new_name = lc $new_name; # lowercase if ($new_name ne $mp3file) { $dir = shell_quote ($dir); $mp3file = shell_quote ($mp3file); $new_name = shell_quote ($new_name); system "mv $dir$mp3file $dir$new_name"; print "\n$mp3file became $new_name"; } } closedir DIR;

In reply to rigthmp3names by zehzinho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.