Time for code review ;)
########################################################### ### not gonna complain about strict, for whatever reason use MP3::Info; die "Must use parameters and seperator\n (SEPERATOR ARTIST TITLE YEAR +ALBUM GENRE COMMENT)" unless @ARGV; $sep=shift; @tokens=@ARGV; while(<*.mp3>) # while is wrong as you move files around, # should be for (grep /\.mp3$/i, <*>) # to insure getting files like "bla.MP3" ### indent your code! { my $tag=get_mp3tag($_) or (push(@errors,"No tag for $_\n") and nex +t); $nn=''; ### now you're using <space><sep><space> as a separator ### I wanted <sep> only. for $i (@tokens){$nn.=$tag->{$i}." $sep ";} my $z=rindex($nn,$sep); my $len=length $sep; substr($nn,$z,$len+1,''); chop $nn; $nn.='.mp3'; ### the last 6 lines should've been something like: ### $nn = join($sep, map $tag->{$_}, @tokens) . ".mp3"; ### and this is not my personal preferrence, but a more ### readable, straight to the point, honest to god statement print "Renamed $_ to $nn \n" if rename $_,$nn; ### where is my error check? } print "\n\n"; print @errors;
And one more final thing which is more important than all of the above blabbering: do "perl name.pl '-' ARTIST" and wonder why all your artists suddenly have one song each.
Or worse: Watch all your mp3s reduced to a singleton ".mp3" as you forget to pass args other than the sep!!.

Hope this helps!!


In reply to Re: mp3 collection renamer by abstracts
in thread mp3 collection renamer by BUU

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.