Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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: # 
    7: 
    8: use strict;
    9: use MP3::Info;
    10: use File::Find;
    11: use File::Copy;
    12: use File::Basename;
    13: use File::Path;
    14: 
    15: my $genre = 'Country';
    16: my $srcdir = '/MP3 Test/';
    17: my $dstdir = 'c:/';
    18: my ($tag, $newdir, $path, $file, $dir);
    19: 
    20: find(\&wanted, $srcdir);
    21: 
    22: sub wanted {
    23:     open(FL, $File::Find::name);
    24: 
    25: if ((/\.mp3/)){
    26: 	$tag = get_mp3tag($_) or print "Could not access tag on $_\n" and next;
    27: 
    28: 	if ($tag->{"GENRE"} eq $genre) {
    29: 		$path = $File::Find::name;
    30: 		$dir = dirname($path);
    31: 		$file = basename($path);
    32: 		$newdir = $dstdir . $dir;
    33: 
    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

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (12)
    As of 2014-10-23 21:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (129 votes), past polls