Automatic MP3 tagging

A requirement for my business was to capture information for every song I had. The information required was the Composer (the person/s that wrote the song), the Year and the Record Label. I have over 13,000 songs and doing this on a manual basis would be an administration nightmare.

So I used my PowerShell skills and set out to achieve what I found was a very reliable manual process, but turned into an automatic process.

The most reliable process that I can find to date is:

  • To grab the Record Label information from iTunes and a site to be used as a backup in the event iTunes didn’t know about the particular song or have the Label information.
  • To grab the Composer and Year information of the song from the same site which had about 95% of my music collection anyway.

A couple of points I will share, this is not 100% perfect, it’s about 95% reliable. Also too, any songs where it can’t find the information for a particular category e.g. Composer, it won’t write that information. In other words, this script will only write the particular information if it can find the particular information. It’s completely non destructive.

The library you will need and what I used to add the all the MP3 tagging information was this library here taglib-sharp however as this library (.dll) allowed me to edit every other ID3 information related to the MP3 except for the Publisher information. I had to modify this library from GitHub, then recompile this in Visual Studio to allow for the addition of editing the publisher information for each song as per this article.

The script is below, edit the top line ($mp3s) to tell it where your music lives, then edit the next line ($taglib) to tell it where to find “taglib-sharp.dll“, then kick it off, you’ll see the output on the screen as it works its way through each song. You might see some Red errors at some points, not to worry, this is where it can’t find particular information for these songs.

The other thing is that this is assumed that your music library is set in a format as Artist – Title.mp3

By the way, the very small percentage of songs it can’t find the information for, you can manually fix these using a site like Wikipedia.