Using a hash for the files that you *are* moving might speed up your program if you have many tracks going into the same directory, but you'd be lucky to see an improvement, even in a benchmark. Besides, speed doesn't appear to be your primary concern here.
Also, where are you getting the album information? Your snippet doesn't get it, though MP3::Info allows you to retrieve it from the same hashref.
2) This sounds more like a design problem than a Perl problem. You need to decide whether you want to sort tracks based on album or artist. Personally, I sort my MP3s by artist then album (i.e. two dirs deep). And yes, soundtracks are difficult. I just have a Soundtrack directory and a directory under that for each movie title.
Perhaps this (untested) code will help get you on track.
#!/usr/bin/perl -w use strict; use MP3::Info; use File::Copy; use File::Find; use File::Basename; find(\&wanted, "/MP3"); sub wanted { /\.mp3$/ or return; my $tag = &MP3::Info::get_mp3tag($File::Find::name,1,1); my $artist = $tag->{ARTIST}; my $album = $tag->{ALBUM}; $artist |= "Unknown Artist"; $album |= "Unknown Album"; $artist =~ s/ /\\ /g; $album =~ s/ /\\ /g; my $dir = $File::Find::dir; -d "$artist" or mkdir "$dir/$artist" or die "Couldn't create $dir/$artist: $!"; -d "$artist/$album" or mkdir "$dir/$artist/$album" or die "Couldn't create $dir/$artist/$album: $!"; move $File::Find::name, "$dir/$artist/$album"; }
In reply to Re: MP3 Mover script
by athomason
in thread MP3 Mover script
by LoneRanger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |