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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |