Got Broken ID3 Tags ?

Problem Description

Much of my digital music collection was not being recognized by iTunes and other players. Even the music I ripped using iTunes wasn't recognized by some players. So I decided it was time to clean up the tags.

When I started taking a look at the state of the ID3 tags, roughly half the song with tags (but not ripped using iTunes) had v2.3 tags that didn't include the song title, or were completely blank. iTunes will happily convert between tag formats, but the default format for songs ripped from CD seems hardwired to use an early version of ID3v2 (v2.2.0) that nobody else uses anymore.

This Particular Solution

I wanted a command line solution that would take advantage of my existing storage organization (directories organized as Genre/Artist/Album) to attempt to automatically generate ID3 tags for a directory of MP3s. At the same time, I expected to have to monitor the process and intervene regularly to provide the correct title of a song.

makeid3tags [options] [<directory_name>]

The options are:

-s
Simulate operation, but don't actually change anything.
-a <artist_name>
Specify an artist name, overriding the use of parent directory name
-b <album_name>
Specify an album name, overriding the use of the directory name
-f
Force modification, even if tags already exist

This script inspects all files ending in ".mp3" in the current directory (or the directory specified on the command line.) The objective is to leave each file with both a valid v1.1 and v2.3 ID3 tag. If a pre-existing ID3 v2.3 (or newer) tag is found, the information will be left untouched and used for the v1 tag (although unexpected tag values will trigger a console message.) If an ID3 v2.2 tag (iTunes) is present, it will be deleted and its information placed in a both a new v2.3 and v1 tag. If no v2.x tags are found, but a v1 tag is found, its information will be used to create a new v2.3 tag. If no tags are found (or the "-f" option is used), the directory name is used for the Album name, the parent of the directory is used as the Artist Name, and the Song name is parsed from the filename.

Other utilities

The id3dump utility is used to examine the ID3 tags of either individual files, or all files in a directory.

A common problem was a pre-existing set of ID3v2 tags that were either completely blank, or missing the song title. These cause problems, as the erroneous v2.3 information would be instead of the (possibly correct) information in the v1 tag. Version 2 tags can be removed using the stripid3v2tags utility, which takes a directory name as its sole argument.

Another problem is a song title generated from a truncated filename. The id3title utility takes a filename and a song title, and corrects both ID3 tags (v1 and v2.3).

The id3album utility provides a similar function for fixing album names

Release Notes

You will need to have the MP3::Tags, Compress::ZLib, and MP3::Info Perl modules from CPAN installed.

Untar the scripts and put them somewhere in your path, like ~/bin.

Known Problems

If the -f option is used to overwrite existing v2.3 tags, the song name is not written correctly in some cases. I'll have to dig deeper into MP3::Tag to fix the problem... The workaround is to use the stripid3v2tags utility to remove the faulty id3v2 tags, and then run makei3tags (again).

Future Improvements

  • A rework of makeid3tags to take either single filenames, directory names, or a combination of the two.
  • Do a CDDB lookup and match files to Album songs, in order to completely fill out the tags describing the music.

Who are we kidding ? These scripts won't get improved until the next time I have to fix a large number of ID3 tags...