Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-12-09 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (36 votes). Check out past polls.

    Notices?