This script will create a folder hierarchy based on the tags of an MP3 file. It creates the folders and puts the MP3s in their respective folder. The folder hierarchy is /artist/album/*.mp3.
#!/usr/bin/perl use strict; use warnings; use MP3::Tag; use File::Copy::Recursive qw(fmove); foreach my $file (<*.mp3>) { my $mp3 = MP3::Tag->new($file); my ($artist, $album) = $mp3->autoinfo()[2,3]; $mp3->close(); s/[\\\/:*?"<>|]//g for $artist, $album; fmove($file, "$artist/$album/$file") or die $!; }
I updated it, removing some unnecessary declarations that were pointed out to me. Thank you!
Re-updated. Got home and made sure the script worked, and it didn't. Now it does. :-) I am thinking of adding more functionality to this, like checking if an MP3's tags are set, and offering to let you set them if they aren't. Any other ideas are welcome!
Re-re-updated. Took CountZero's comments into consideration, and removed unnecessary delcaration of some tag information.
In reply to Create folder hierarchy based on MP3 tags by thmsdrew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |