Managing your music library tags with Perl

I wanted to get into Perl, and this is an excellent occasion for that. We want to modify the tags of all our mp3 files. Tedious to do by hand, so we need some script-fu.

Here is what I came up with (my first perl script so it can surely be improved) :

    use strict;
use File::Find;
use File::Basename;

my $base_path = '/MyMusic/Thelonious_Monk'; find(\&wanted,$base_path);

sub wanted {
chomp $_; my @exts = qw(.mp3 .txt); my ($name, $path,$ext) = fileparse($_, @exts); if ($ext eq ".mp3") {

$id3v2 -a Debussy Cathedrale_engloutie.mp3 So we only need to run this command in the shell script and voilà! Of course, you can use the filename to update the title tag for example. ## Remarks • A variable begins with a dollar sign, an array with a @. • The$_ is the current variable in the function.
• The function chomp remove the ending trail.
• At the end, wanted defines a function.
• The strict module is for debugging

## Edit

I have created 3 scripts to manage huge library of .flac files, which can be found on Github in the Splitting music files section.

• First, split all the .flac files with split_all.pl (edit the proper variable to define the location of the folder)
• Then, run check_split.pl to check the splitting was done properly.
• Finallly, finalize.pl removes the temporary folders and place the files in their proper location.

Please note I hacked together these scripts so you may have to do some editing (for example, you can modify them to adapt to .ape files).