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) :

What does it do ?

We first find all the files in the $base_path folder with the find utility. Then we use fileparse to get the extension and the basename. If it is an MP3 file, then we will change the ID3 tag. For that, we use a command-line utility called id3v2. With that, we can simply change the composer of a music with :

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.


  • 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


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 (edit the proper variable to define the location of the folder)
  • Then, run to check the splitting was done properly.
  • Finallly, 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).