This is a perl script for inteligently setting ID3 tags on mp3 files. It will
read id3v1 and id3v2 tags and formulate a new set of tags. The user can set
which tags should take preference. The script can also use directory
information to help determine appropriate tags. After the script determines as much info as it can it will ask the user to validate the tags and make changes if necessary.
Version 0.04 added support for newer version of MP3::Tag (tested with version 0.40) and fixed a bug where an empty year tag could be created which confused some software (JEmplode).
Version 0.03 added support for stripping old id3 tags. Make sure the preference for this is set (near the top of the source) the way you want it before running this script.
I currently only set a few ID3 tags that are common to both ID3v1 and ID3v2. Anyone with a little perl experience should be able to modify this to work with additional tags. Currently this supports...
Title
Artist
Album
Genre
Year
Track
Comment
This script expects to receive a single mp3 file as an argument. For example...
# perl id3_tag.pl ./artist/album/file.mp3
This script can use properly formatted directory info to add to the tag info.
This will work if your mp3s are in one of these formats...
./artist/album/title.mp3
./artist/title.mp3
./artist - album/track - title.mp3
./album/artist_track_title.mp3
You can add additional formats by modifying the regular expressions near the top
of the file.
I recommend that you use another program like find to call this script on each
of your mp3 files. For example from the directory that contains all my
subdirectories (sorted by artist) of mp3s I would run...
# find . -name \*.mp3 -exec perl id3_tag.pl {} \;
This will recurse through all of the sub directories calling id3_tag.pl on each
mp3 file.
There are also several preferences near the top of the script that you may wish
to check out.
The script will prompt the user to verify each tag and modify them if necessary.
The script will then write both the v1 and the v2 tag to the file so that the
tag info is available to programs that can read either tag type.
This script is setup for a unix like directory structure. You will need to
change the path to perl and probably the regular expressions that determine the
directory info in you are not using a unix system.
Requirements: This script requires the MP3::Tag perl module which is available
from your favorite CPAN mirror or http://tagged.sourceforge.net
License: This script can be used and redistributed by anyone for any purpose and
modified in any way without attribution. If you are using it feel free to send
me an email so that I know how many people are interested in this.
Disclaimer: This script will modify your mp3 files using a perl module that I
did not write and have no control over. Both this script and that module could
damage your mp3s, reformat your hard drive, and cause your computer to
spontaneously combust. I take no responsibility for any bad things that
happen. Back up any files that your care about before using this script.
Other: I spend most of my software writing time with java so my perl skills are not that great and my programming syntax looks like C++. This will probably offend any serious perl hackers. Deal.
| Attachment | Size |
|---|---|
| id3_tag.pl.txt | 7.86 KB |