Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
    0: #
    1: # Copies MP3s by genre tag using sources directory tree.
    2: # Script must be executed from the source's root
    3: # i.e. $srcdir must be a path on the same drive as where the script is executed from
    4: #
    5: # Criticism/advice appreciated
    6: # 
    8: use strict;
    9: use MP3::Info;
    10: use File::Find;
    11: use File::Copy;
    12: use File::Basename;
    13: use File::Path;
    15: my $genre = 'Country';
    16: my $srcdir = '/MP3 Test/';
    17: my $dstdir = 'c:/';
    18: my ($tag, $newdir, $path, $file, $dir);
    20: find(\&wanted, $srcdir);
    22: sub wanted {
    23:     open(FL, $File::Find::name);
    25: if ((/\.mp3/)){
    26: 	$tag = get_mp3tag($_) or print "Could not access tag on $_\n" and next;
    28: 	if ($tag->{"GENRE"} eq $genre) {
    29: 		$path = $File::Find::name;
    30: 		$dir = dirname($path);
    31: 		$file = basename($path);
    32: 		$newdir = $dstdir . $dir;
    34: 		if (! -d $newdir ) { 
    35: 			mkpath ($newdir, 0666) || die "can't mkdir $newdir: $!\n";
    36: 		}
    37: 		copy($path, $newdir . '/' . $file) or die "copy failed: $!\n"; 
    38: 	}
    39: }
    40: 	close(FL);
    41: }

In reply to Copy Mp3s By Genre by mumbles

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (3)
    As of 2020-06-03 02:51 GMT
    Find Nodes?
      Voting Booth?
      Do you really want to know if there is extraterrestrial life?

      Results (19 votes). Check out past polls.