• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Playlists, Tags, and Skins: M... > ID3 Tags and Playlists: The Virtual ...

4.3. ID3 Tags and Playlists: The Virtual Database

ID3 tags and playlists are two of the most important extended topics for people who take their MP3 collections seriously. Taken separately, both technologies are important in their own right, but taken together, these two functions can complement one another in very powerful ways, giving you the means to sort, store, organize, name, and build highly customized virtual collections. Because these two technologies are so synergistic, and because many tools exist to help you organize both of them simultaneously, we'll treat both of them together in this section.

4.3.1. What Are ID3 Tags?

Every MP3 file has the ability to store "meta-data" related to the track in the file itself, in the form of what are known as "ID3 tags." For example, a file's ID3 tags may store the song's artist, album, year, genre, and comments in ID3 tags. Many MP3 players have the ability to read ID3 data out of your files, and to display this information in the MP3 playback interface. Thus, giving your MP3 files descriptive names isn't the only—or even necessarily the best—way to identify the tracks in your collection.

Conveniently, ID3 tag information can either be included in the file at the time it's encoded or added in later. Most of the better encoders will provide a number of options to let you control whether and how ID3 tag data should be written to the file. While some MP3 players include the ability to edit, as well as to display ID3 tag information, you may want to download and install additional utilities that specialize in ID3 manipulation, for maximum control. We'll look at some examples of ID3 tag editors later on.

4.3.1.1. ID3v1 vs. ID3v2

It's important to understand that there are two basic flavors of the ID3 specification, conveniently named ID3v1 and ID3v2. Of the two, ID3v2 is vastly superior, for three reasons:

  • Unlike ID3v1, ID3v2 imposes no arbitrary limitations on the amount of storage space available for meta-data, which means there's plenty of space for storing images, complete lyrics, performance notes, equalization presets, et cetera.

  • ID3v2 data is stored at the beginning of the file, rather than at the end. This means that ID3v2 is much better for use in streaming situations, where it's important that users be able to see and use the meta-data while the song is being played, rather than after the download or broadcast is complete.

As useful as it can be to have ID3v2 data appear at the beginning of the file, this state of affairs also presents a problem—especially for older players. A player built to the ISO spec should simply skip over the ID3v2 data that it doesn't understand, and move ahead to the valid MP3 data. But exactly how far should the player seek through the file for an MP3 header frame before giving up and deciding that it's not currently dealing with an MP3 file after all? Unfortunately, the ISO spec is vague on the matter, which leaves the door open to interpretation by developers. Some believe that a player should seek forever (after all, ID3v2 data can occupy as much as 256 MB of space), while others feel that a player should give up after a certain number of bytes and assume that they're not dealing with a valid MP3 file after all. The user could have innocently tried to play a giant AVI movie through his MP3 player, for instance, which would cause a player that seeks forever to basically hang. Since the spec is not clear on the matter, the debate may never be resolved. The best solution may be store this data separately, in a hypothetical, centralized MP3ID database, for example, although that's just one of the ideas being floated around.

  • The ID3v2 spec is open-ended and flexible, meaning it can be extended in the future to accommodate as-yet-unseen needs. Users may even be able to develop their own custom solutions, given the availability of future ID3v2 tag editors and management solutions. For example, the built-in "Popularimeter" field could be used to let users rate all of their tracks on a scale of 1 to 100, and then create custom playlists based on a scale of favorites.

The number of possible applications for ID3v2 data is staggering. Right off the bat, it gives artists and labels a place to store copyright information, terms of use, and proof of ownership. There are even possibilities for cryptographic security being embedded in MP3 files, thanks to ID3v2. For the end user, ID3v2 means the ability to store full-size, color scans of album covers, complete lyrics (even synchronized lyrics, for use in Karaoke situations), multiple URLs for further information, music reviews, extended information on the recording session, and so on.

While users of ID3v1 players sometimes discovered that the spec, with its 32-character limitation, didn't even give them enough space to store very long artist or album titles (such as Stereolab's album "Cobra and Phases Group Play Voltage in the Milky Night"), the ID3v2 spec allows for a maximum of 256 megabytes of additional tag storage space, meaning users won't bump into arbitrarily imposed limitations. Of course, if you fill a file with 256 MB of ID3 data, don't expect many users to want to download it from your site.

Because a surprising number of older players are not ID3v2 aware, and because of the problem mentioned earlier regarding the length of time an older player should seek for MP3 data before giving up, problems do arise. For example, if you use MusicMatch Jukebox to embed an image of an album cover into an MP3 file using Jukebox's ID3v2 tag editor, you'll find that the file will no longer play in the command-line mpg123 player, while Xmms may be able to play the file but won't show any ID3 tags for it.

Despite these issues, ID3v2 is a spec with huge potential. One of the most popular applications to take a stab at the ID3v2 space is MusicMatch JukeBox. At this writing, ID3v2 support in MusicMatch was limited to a minority subset of the total frames available (although these were the most significant ones). In addition, MusicMatch was taking a proprietary approach to storing some categories, including tempo, preference, and mood, which some feel could have been better handled had MusicMatch gone with standard ID3v2 frames. Finally, MusicMatch's implementation of the Content Type frame was still incomplete, and resembled ID3v1 more than ID3v2. Still, somebody had to be first on the dance floor, and the company's commitment to driving the standard forward should be appreciated. However, there's a lot of work remaining to bring their product into full compliance with the specification.

So how do you tell which ID3 spec is in use on any given file? There's no way to get this information just by looking at a file; the best way is to open the file in a tag editor capable of reading both versions of the spec, and looking to see where in the editor's fields information shows up. Any older MP3 file can be "upgraded" simply by opening it in an ID3v2-capable player or editor and adding extended information to it. In fact, some utilities will automatically migrate all ID3v1 data to equivalent ID3v2 fields. Opening an ID3v2-enhanced MP3 file with an older player will probably result in you seeing nothing in the ID3 info fields. The file itself, however, should still play properly. If it doesn't, you should consider changing or upgrading your MP3 player software.

Having accurate information in your files' ID3 fields is important for several reasons. If you ever edit or screw up your file's names, you can always just open the file in an ID3-capable player, read the author and song title, and rename the file accordingly. Some tools will even do this for you, automatically and programmatically, so you can assign ideal file names to every MP3 track on your system. ID3 tags are displayed in many playlists, so that you can display only song names, only artists, or only the comments. ID3 tags are commonly used by hardware MP3 players such as portable "Walkman"-type devices and home MP3 units. And some programs and utilities will let you treat the ID3 info in your files collectively, as if your entire collection was a huge, multi-field database.

For more information on the ID3 spec and its evolution, see the ID3 Standards Group web site at http://www.id3.org.

4.3.2. What Are Playlists?

After all the talk about how the MP3 revolution represents a rebirth of the "custom cassette" revolution of the '70s and '80s, the arena of playlists is where you finally get to see that promise become a reality. In their simplest form, playlists are simply text files containing paths to MP3 files on your system—one line in the file for every track referenced. The beauty of playlists is that they can be constructed to reference arbitrary tracks, rather than being limited to entire directories. For example, you might have a playlist referencing only the tracks in your collection in the Free Improv genre, or all tracks by The Carpenters, or all tracks you're temporarily storing in a holding bin until you decide what to do with them. There are many ways to construct playlists. Most users will create them by simply dragging tracks (or entire directories) out of the system's file manager (Explorer/Finder/Tracker, etc.) and into an open playlist window, then saving the new playlist to the hard disk. However, playlists can also be constructed from the command line by way of scripts, or from database searches. As you'll soon see, real playlist flexibility comes into play when you use your files' array of ID3 tags to search on specific criteria, then save the resulting found set as a playlist file.

Because they're constructed with such simplicity, playlists are nearly universal; for the most part, a playlist created with any method will work in any MP3 player (on the same operating system). Of course, the exact format of the lines comprising a playlist depends on the path style on your operating system. For example:

DOS/Windows - C:\DATA\MP3\ALBUMS\CAN\DELAY\PNOOM.MP3
Mac OS - Main HD:Data:MP3:Albums:Can:Delay:Pnoom.mp3
Linux - /usr/local/home/shacker/data/MP3/Albums/Can/Delay/Pnoom.mp3
BeOS - /gorgonzola/home/data/MP3/Albums/Can/Delay/Pnoom.mp3

So while a playlist will work on any MP3 player on your operating system, it wouldn't on another OS. (This really isn't much of an issue though, since people organize their collections very differently and it thus makes little sense to share your playlists with others, unless you're trading around data CDs full of MP3 files). Even if you're a Linux or BeOS user storing your MP3 collection on a Windows partition and then accessing it from Linux or BeOS, the paths to the files on the Windows partition will still appear differently, so you won't be able to share playlists between different OS partitions.

It's worth noting that most users will seldom see the actual text of a playlist file. While you can open a playlist in any text editor for viewing or hand-editing, it's almost always easier to view and manage your playlists directly in your MP3 player's built-in playlist manager, since these typically give you drag-and-drop, shuffle, sort, total playback time, and other MP3-specific features you probably won't find in a text editor. Playlist manager/editors generally do not show you the full paths to your MP3 files, displaying only the actual track names. In many cases, playlist editors will read the ID3 tags out of each file in the list and display those (if found) rather than the filenames. As you'll see in Chapter 8, playlists may also contain the URLs to MP3 files on the Internet, so that you can stream known favorites "out there" directly to your MP3 player.

Because most MP3 players can accommodate multiple audio file formats, including WAV, RealAudio, AAC, and others, there's no reason you should restrict your playlists to referencing MP3 files alone. If you've been collecting multiple audio file formats on your system and your player supports them all, feel free to create playlists referencing multiple file formats. If such a playlist does get fed through a player that doesn't understand some of the referenced formats, it should gracefully skip those files (assuming it's well-designed).

4.3.2.1. Playlist formats

The form of playlist described above is known as an M3U list,[#] and is named as playlist.m3u . In some cases, you may also encounter playlists with a .pls extension. These files are virtually the same, with a couple of internal differences. They begin with an identifying block marking the file as a playlist, precede each track with a numerical identifier, and close by listing the total number of tracks referenced. .pls files don't always reference the full path to each track, so if you move a playlist to another directory, disk volume, or hard drive on the same system, it won't work. .pls files are often dished up by streaming MP3 SHOUTcast/icecast servers, since the .pls format allows for the distribution of meta-data.

[#] For "MPEG Layer 3 URL"; the URLs contained by these files can be either local files on the user's system or remote files "out there" on the Internet. The MIME type for M3U files is audio/x-mpegurl.

When creating playlists on your own machine, you'll almost always want to stick with .M3U for maximum compatibility with a wide variety of MP3 players. If you do need to create a .pls file, you'll find the option in the "Save Files as Type" picklist in the file panel when you access your playlist's Save function.

Finally, there are a few applications that create their own custom playlist formats. A good example of this is the Apollo MP3 player for Windows (apollo.mp3-2000.com), which combines an MP3 player and sophisticated playlist manager into a single application. While Apollo offers a number of cool playlist features that others do not (such as ID3v2 support and the ability to create lists from arbitrary ID3 criteria), its playlists are only useful with Apollo itself.

4.3.2.2. Loading and manipulating playlists

Playlists can be loaded into your MP3 player in several ways, depending on the platform and the specific player. In most cases, the easiest way to load a playlist is to simply double-click its icon. If it's been properly associated with your MP3 player, it will launch the player with that list preloaded. Playlists can usually be dragged onto your MP3 players' interface, or loaded from the File → Load button in the player's playlist editor. If you're a command-line junkie, you can usually load a playlist by typing:

<path to player> <path to playlist>

WinAmp users can right-click a playlist file in Explorer and choose Enque from the Context menu. If a playlist is already playing, this one will start playing when the current one has finished. You can queue up a pile of playlists to play sequentially in this way.

Most playlist editors include a number of functions designed to let you sort the order of tracks by song name, artist, length, and other criteria, though "Randomize" seems to be far and away the most popular means of "organizing" playlist tracks. If you're using Windows and are dropping files into a playlist editor, note that a peculiarity of Explorer could end up frustrating your attempts to get them to appear in same order you selected them in. However, if you select the last file first in Explorer, hold down the Shift key, and then highlight the first file; you can drag the whole block into your playlist editor and have the selections appear in the right order. In other words, the order in which you begin your selection in Explorer is the reverse of the order in which the selection is passed to other applications. You gotta love it.

Most playlist editors include a set of buttons (or a pull-down menu) separate from that of the MP3 player itself. WinAmp's playlist editor, for instance, includes buttons that will let you add entire directories or URLs to the playlist window, remove all selected files or all "dead" files (i.e., references to files which no longer exist at the specified location), sort your playlist by a variety of criteria, or save your playlist. To access the ID3 info for any file in WinAmp, select it in your playlist and tap Alt+3.

You can also generate HTML playlists directly from WinAmp's playlist editor. With the editor open, click Misc Options and select Generate HTML Playlist (or just tap Ctrl+Alt+G). The current list will be sent directly to your default browser. You can then pull down File → Save in the browser to store the resulting HTML document for future reference.

4.3.3. ID3 and Playlist Editors

There are seemingly infinite numbers of ways to create interfaces onto ID3 tag data (Figure 4.2), and we can't hope to cover a fraction of them in this book, but here are a few examples of the creative ways ID3 tags can be accessed, displayed, used, and edited, in various operating systems.

Figure 4-2. A WinAmp's built-in ID3 tag editor


4.3.3.1. Windows

MP3 collections are becoming larger, and large projects lend themselves well to database-like solutions. Since the array of all tags in all of your MP3 files, considered together, pretty much amounts to a database, the real trick is in building a good interface onto that database, letting you view and edit ID3 tag data, rename files based on existing ID3 tags, see the collection of all ID3 tags in a database-like manner, search that database on custom criteria, and generate playlists from the results. If you want to do all of these things, you have two choices. You can scan your favorite software library for individual tools that serve one or more of these functions (and probably get it all done for free, but create a lot of busy work for yourself), or you can grab an all-in-one tool like Helium (http://www.intermedia.st/helium/). While most of the all-purpose tools will probably cost you a few bucks, they'll more than pay for themselves in the time they'll save you in the long run. Since, at this writing, Helium is one of the best all-purpose ID3/database/playlist tools available, and because it covers the general principles involved in performing all of these tasks, we'll focus on Helium in this section. Note, however, that there will likely be other, perhaps better, tools available for your operating system by the time you read this.

Figure 4-3. The main Helium window


The main Helium window plays host to any number of what are known as "Browsers," where a browser is simply a table of MP3 files: a sort of fancy playlist (Figure 4.3). To create a new browser window:

  1. Double-click on the Helium background. Point the empty browser to an MP3 directory or collection of files by clicking the Add Files or Add Dir buttons on the left.

  2. All MP3 files in that directory and its subdirectories will appear in a table, along with any ID3 tags stored in those files. If the referenced files don't include MP3 tags and you want to give them some, select those files in the browser and pull down Tools → Edit Tags (or tap Ctrl+E).

  3. An ID3v2 tag editor will appear for the first selected file, offering tons of fields, picklists, and text boxes into which you can type or paste lyrics, select genres, and so on (Figure 4.4).

  4. When finished editing a file's tags, click Save, then Next to move to the next file in your selection.

Figure 4-4. Helium's tag editor offers the majority of ID3v2 frames; buttons along the top let you navigate amongst major classes of allowable ID3v2 data


Helium is also capable of renaming files singly or in batches, based on the contents of their ID3 tags (though the version we tested did not offer special character or blank space substitution, which we feel should be a mandatory feature). To access the renaming function, select a file or files and pull down Tools → Rename Files. As with other ID3 renaming tools covered in this section, you have partial control over the format of the filenames that will be created, via a template function accessed from Helium's Output Editor. Conveniently, Helium lets you store as many naming templates as you like. A couple are built in, but you'll probably want to create your own as well. Click the New button, and then the Tag Help button to see a list of all allowable field strings. Artist/Group is represented by the symbol %00, Title by 01%, Album by 05%, and so on. So if you've got a file called file1.mp3 and its ID3 tags specify that this is "Blue Jay Way" from the Beatles' Magical Mystery Tour, you could set up a template of the form:

%00%05%01

Renaming your file with this template selected will result in a file called:

BeatlesMagical Mystery TourBlue Jay Way.mp3

That, however, is probably not what you want. To add separators between the fields, enter them in the Prefix and Suffix fields.

Helium is capable of exporting lists in two ways. Before you do, however, you'll probably want to use some of Helium's filtering and sorting capabilities—here's where the real power of a database begins to come to light. Let's say you've got hundreds of folders full of MP3 files scattered around on your hard drive, and you want to make a playlist of all songs with their Genre tag set to "Booty Bass." If you haven't already assigned Genres to your tracks, use the Tag Editor to do so. You'll also need to make sure the Genre column is showing in the Browser table—you can enable this from Helium's preferences panel. Now pull down Edit → Search, type in "booty," make sure the "Copy matches to new window" checkbox is selected and click Search. All songs in the main browser window that are tagged as Booty Bass songs will appear in a new Browser. Now all you have to do is pull down File → Save Playlist, select either the .M3U or .pls format, and save. Bingo—instant custom playlist.

In addition to playlists, Helium is capable of generating HTML or text documents from its browsers, so you can keep documents on your desktop that list your entire collection of MP3 files, or any custom subset thereof. Select a set of files or create a new browser containing customized search results, and click the List button. The output format of Helium's list generator can be completely customized by specifying HTML or other header data, and then inserting ID3 tag symbols into the Main List section of the List Generator.

Because of the inherent power of database-driven tools, you'll find that applications like Helium become increasingly indispensable as your MP3 collection grows larger.

4.3.3.2. One-click master list

How would you like to be able to double-click a single icon on your Desktop, have it scan your system for MP3 files, generate a master playlist, and launch that playlist into WinAmp or another MP3 player? A batch file (that's DOS-ese for shell script) like the following one can make this easy. To do this, you'll need to invoke the ancient masters of your early DOS training.

Generating a playlist from the DOS command line (i.e., DOS prompt) is a matter of constructing a command that will find all files ending in .mp3 in a specified directory and all of its subdirectories, that will not spew out all kinds of extra data you don't need, and that won't list directory names themselves. Here's what you want:

dir c:\data\mp3\*.mp3 /s/b/a-d > c:\data\playlists\thislist.m3u

If you scatter MP3 files all over your system (which wouldn't be very good housekeeping), you can change the initial path to simply C:\. In case you're curious about those switches, /s tells dir to recurse down through subdirectories. /b tells dir to output only a simple list of pathnames, without file sizes, or foreshortened filenames. /a tells dir to handle special attributes, as specified in its subsequent arguments. d is one of the attributes /a can handle, and since we precede it with a - instead of :, we're telling dir to ignore directory names themselves (directory names in playlists will simply be ignored by most players, but they're still messy). The > symbol is a redirect, and tells DOS to dump the output of the command to a new file. Of course you'll need to substitute in the path to your collection of MP3 files, as well as the preferred path to and name of your generated playlist file.

If you want to do this sort of thing in a batch file, so you can simply double-click an icon on your desktop to have the whole thing run automatically, you'll want to create something like this:

@echo off
echo.
echo Creating playlist from d:\data\mp3 ...
:: Remember to edit the paths below to match
:: those on your machine! The second line is optional,
:: and shows how you can have this batch file scan through
:: multiple drives and directories and append the results 
:: to the same playlist file. Note that if any of your directory
:: or filenames are longer than 8.3 you'll need to surround
:: them in quotes so DOS doesn't get confused.
dir d:\data\mp3\*.mp3 /s/b/a-d > "d:\data\playlists\alltracks.m3u"
dir e:\hold\music\mp3\*.mp3 /s/b/a-d >> "d:\data\playlists\alltracks.m3u"
echo.
echo Launching the new list in WinAmp...
:: The next line can be the the full path to any MP3 player
:: on your system that accepts a playlist as a command line
:: argument. WinAmp handles this just fine.
start "C:\Program Files\Winamp\winamp.exe" "d:\data\playlists\alltracks.m3u"
exit

					  

To test your new system, double-click the batch file in Explorer. Did it work? Good. Unfortunately, you will have noticed that a DOS shell is launched automatically when you run the batch file, and doesn't close itself when you close WinAmp. The trick to fixing this annoying behavior is to click the small Properties icon in the DOS shell's menu bar and check the "Close on exit" checkbox (you may also want to select "Run: minimized" to keep the DOS window from flashing briefly on screen). Close the Properties panel, and a .PIF file will be created in the same directory as the batch file, appearing as a standard Shortcut file. Drag this shortcut to your Desktop or wherever, and from now on you can just click that to launch your script. The DOS shell will close as soon as WinAmp launches.

4.3.3.3. Do it with Perl

Search the Internet and you'll find tons of homebrew playlist solutions created by ordinary people, using free tools. One of the most common and useful such solutions is the Perl-based playlist creator, such as the one created by Patrick Hearon and available at http://www.owlnet.rice.edu/~patrickh/playlist.html. Point the script at a directory tree and it will "walk" through its contents, taking note of any MP3 files it finds in the path. When finished, it will generate either a plain text .M3U playlist file, suitable for use with any MP3 player, or a collection of HTML files, one in each directory, each listing the contents of that directory. Because each file automatically links to the others, you can browse through your MP3 collection easily, or post the HTML documents on a web site for others to peruse.

Perl junkies may also want to search CPAN (http://www.perl.com/CPAN/), a.k.a. the Comprehensive Perl Archive Network, for all sorts of useful Perl modules. At this writing, MP3.com was in the process of contributing some of their own modules into the CPAN database, including modules to give Perl built-in ID3v2 and MPEG Layer 3 info support (a less complete module already exists).

Because Perl is available for nearly every platform known to humankind, these scripts can be easily tweaked to work with your platform (though all you'll have to change are the magic cookies pointing to the Perl interpreter, and the path style used on your system).

4.3.3.4. Mac OS

Most of the popular MP3 players for the Mac include built-in ID3 tag editors, and usage is straightforward, as you might imagine. In MACAST, for example, make sure the playlist is showing, select a track, and click the Info button. Fill in or edit the fields as desired, then click Save to save your changes directly into the file, as shown in Figure 4.5. At this writing, MACAST supports only ID3v1 tags, though ID3v2 support may be available by the time you read this.[**]

[**] In fact, a Lyrics field was available in the ID3 tag panel in the version of MACAST we looked at, and lyrics are officially a part of the ID3v2 spec. However, ID3v2 offers a much broader array of options than just lyrics, so we consider this to be only a partial implementation of ID3v2 support.

Do not attempt to edit ID3 tags in a currently playing track. MACAST will issue a warning and offer to move to the next track in order to make changes to the current track, but in our experience this froze the Mac.


Figure 4-5. A MACAST window's Info button produces fields to fill in or edit; just fill in the fields and close the MATE window to save your changes


More powerful than the built-in tag editors is a piece of freeware called mp3tool, which will scan a specified folder for MPEG files and let you edit ID3 tags in any files it finds along the way. While mp3tool won't create playlists from the files it finds, it offer very straightforward tag-editing capabilities. Search your favorite Mac OS software library for mp3tool.

Since Mac OS doesn't have a command-line environment, it's not possible to create scripts that perform similar functions to the DOS batch file above or the Unix shell script below. However, if you're familiar with AppleScript, it should not be difficult to store references to your MP3 files in a commercial database (such as FileMaker Pro) or spreadsheet and extract the results of database searches to a plain text file. Alternatively, you can use the Finder's Find panel to scan your system for all MP3 files, then drag files in the resulting list onto the Desktop or into a folder. From there, you can drag files directly into your MP3 player. However, because you can't drag files directly out of the Find panel and into a player, this process essentially means moving your MP3 files around, which is probably not what you want to do. However, you can drag files out of the Find panel and onto the MP3 player application icon. In the end, you're probably better off using the MP3 finding tools built into the players themselves.

4.3.3.5. Linux

The power of Unix-based operating systems is often at the command line, and ID3 handling is no exception. One of the most popular tools available for handling ID3 tags under Linux is id3ren (tscnet.com/pages/badcrc/apps/id3ren/), a multi-purpose tool that can not only read and write ID3 tags, but can also rename files based on the ID3 tags those files contain. While id3ren is most popular under Linux, note that BeOS and Windows ports of id3ren do exist, and can be found at your favorite software library. The real power of a tool like this is in its ability to be embedded in shell scripts and run over batches of files at once.

To see the tags currently attached to filename . mp3, type

id3ren -showtag filename.mp3

To rename a file with the default (built-in) naming template, just type:

id3ren filename.mp3

If the file's Artist tag was "Beatles" and the Title tag was "Taxman," filename . mp3 will be instantly renamed to [Beatles].[Taxman].mp3. Don't ask me where that goofy default format comes from, but fortunately, you can easily change this by means of the -template argument. Templates in id3ren are a means of defining the naming structure of the files to be renamed, where the following identifiers are available.

Tag Identifier
%a Artist name
%c Comment
%s Song name
%t Album title
%y Year
%g Genre


So, for example, if your file's Artist tag is set to "Beatles" and the Title tag is set to "Taxman," you can have the file renamed as Beatles—Taxman.mp3 with the following command:

id3ren -template="%a--%s.mp3" filename.mp3

If you always want to use the same template, and don't want to have to specify it every time, create a text file called .id3renrc and place it in your home directory (see id3ren's documentation for more on allowable locations). In this file, specify the same template parameters, but leave out the quotes. id3ren will now always use your preferred template, unless you use the -nocfg flag in your command. Windows users will need to replace the % symbols with $ in the template examples here.

The simplest way to add to or change the tags associated with a given file is to type:

id3ren -tag filename.mp3

You'll be prompted to enter a string for each of the possible tags. Alternatively, you can add multiple tags at once with a single command, like this:

id3ren -tag -song "Mink_Shmink" -artist "Eartha_Kitt" filename.mp3

You'll then only be prompted for any tags you don't enter in the command (including -comment, -genre, and -year). If you don't want to be prompted for other tags, add the -edit argument. If all you care about are the Artist and Title tags, and don't want to be prompted for others, use the -quick flag. If you don't want the file to be renamed, and only want to edit tags, use -tagonly. To simply remove all tags, use id3ren -striptag filename . mp3. You get the idea. There are many more options available, but they all follow this basic model—just use id3ren -help to see them all.

The real power of id3ren, of course, comes into play when dealing with batches of files at once. In any of the example commands, wildcards or variable names can be used in place of filename . mp3. Thus, you can easily run through an entire directory of files at once. Since a directory might very well represent an entire album, you'll probably want to specify the artist and album names in the initial command, so you don't have to type them in over and over again. For example, let's say you just ripped and encoded all of Magical Mystery Tour, but the MP3 files you've created have been given names like Track1.mp3, Track2.mp3, and so on. The following command will give the files appropriate names, add the Artist and Title tags, and prompt you only for the song titles, skipping the year and comments:

id3ren -tag -artist "Beatles" -album "Magical Mystery Tour" -nogenre \
-nocomment -noyear -template="%a-%s.mp3" *.mp3

id3ren will prompt you for the name of each song in the current directory, write the song, album, and artist tags to each file, and rename each song as Beatles-Taxman.mp3 and so on. If you don't mind being prompted for the genre tag with each song as well, you could use the -quick flag for a somewhat shorter command.

The following script can be used to sift through all of your MP3 files for just those files whose ID3 tags match criteria you specify. This sample script looks for matches on the Artist tag, though you can tweak it to search on the Genre tag, for example, "find me all songs that are filed under the Genre (`Gangsta')." Further adjustments could yield a script that searches on two criteria at once ("all Soul tracks from 1971"), or just about anything else you can imagine:

#!/bin/sh

# Get the artist name passed in from the command line
Artist="$*" 

# Edit the next line to equal the full path to your main MP3 directory.
# To search your whole system, you could even make it " / ", 
# But the more specific you are, the faster the script will be.
MP3Path=~/mp3

# Set this to the location in which you want your playlist files
# to appear. This universal HOME variable should work on all
# Unix-based systems, though you'll probably want
# to customize it.
PlayListDir=${HOME}

# Now we'll get a list of all MP3 files living in the MP3 hierarchy.
# The list will be saved to a temp file for further parsing.
find "$MP3Path" -name *.mp3 > $PlayListDir/.id3-tmp

# Now we're going to open that temp file and examine each track
# it references, trying to determine whether its Artist tag matches
# the one the user specified on the command line. We have to do
# a little fancy work with grep and sed to get just the info we need
# and nothing else.
{
while read ThisFile; do
	ThisArtist=$(id3ren -showtag "$ThisFile" | grep "Artist\:" | sed s/Artist\:\ //)
		if [ $ThisArtist = "$Artist" ]; then	
			echo "$ThisFile"
		fi
done

# Input is the temp file, output is the final playlist
} < $PlayListDir/.id3-tmp > $PlayListDir/$Artist.m3u

# Remove the temp file
rm $PlayListDir/.id3-tmp
exit
                  
               

					  

4.3.3.6. BeOS

There are a number of tools for BeOS ID3 tag display and manipulation. All of the major MP3 players support normal ID3 display within their own interfaces, but BeOS also supports some ID3 manipulation not possible on other platforms. Because the Be file system supports "attributes" (data associated with a file that is not a part of the file itself), ID3 tags can be read out of MP3 files and displayed directly in the Tracker (the BeOS file manager), as shown in Figure 4.6. This provides an excellent database-like interface you can use to sort, query, and organize your MP3 tracks along user-selectable criteria.

Figure 4-6. BeOS lets you store ID3 tag info as filesystem "attributes," which can then be displayed and edited directly in the Tracker


One of the most useful tools you'll find out there is a collection of Tracker add-ons and applications by Jonas Sundström (see http://www.be.com/beware/). Install Tag2Attr and Attr2Tag in your /boot/home/config/add-ons/Tracker folder, then right-click any MP3 file or collection of MP3 files and select Tag2Attr. All of the selected files will be examined for embedded ID3 tags, and attributes will be written to the file system. You can now enable the MP3 attributes you want to view from the Tracker's Attributes menu, and edit your attributes directly in the Tracker. Because other operating systems don't recognize BeOS attributes, you'll want to make sure these attributes are written back into the file itself if you edit any of them (and plan to make them available to users of other OSes); hence, Attr2Tag works exactly the same, but in the opposite direction.

While this pair is excellent for batch jobs, you may find you want more control. Sundström is also the author of TagWorld, which is also a Tracker add-on, but lets you examine and edit the collection of tags for each file individually (see Figure 4.7).

Figure 4-7. TagWorld lets you copy ID3 tags to attributes and back again


In order to query your BeOS system on ID3 data, you'll need to tell the filesystem to maintain an index of the ID3 attributes. Sundström also provides MP3 AI to help you create and manage the necessary indexes, as well as MP3 Flashlight, which makes finding MP3 files even easier than it is from the system's Find panel. Taken together, Sundström's collection of tools exploits native BeOS features to gain functionality similar to that found in Windows with tools like Helium (covered earlier in this chapter). Many BeOS encoding tools will write ID3 tags to attributes as they're encoding, and can even create custom folder layouts based on GUI templates. More on that in Chapter 5.

If you prefer to work from the bash shell, or if you'd like to script some of these behaviors, download a copy of Ari Pernick's id3attr from http://www.be.com/beware/. Once installed, you can copy ID3 tags to attributes by launching a Terminal and typing:

id3attr *

The author also keeps this alias in his ~/.profile:

idren='id3ren -template="%a - %s.mp3" -space=" "'

By using the id3attr * command followed by the custom idren command, he can "database" and give ideal names to a batch of freshly downloaded MP3 files in seconds.

Once your MP3 files have attributes attached, there's almost no limit to the ways you can create custom playlists. For example, if you want a playlist consisting of all the MP3 files in your collection written in 1971, just do a normal system query (pull down the Be menu and select "Find") on "MP3 → Year contains 1971." Select All in the query results window and drag the selection into an open playlist window. Save the new playlist, and you're done. Of course, you can extend the same principle to create playlists of any complexity. For example, you could create a playlist in three seconds flat consisting of all Neil Sedaka tunes that have a Comment field including the word "smarmy." Pretty cool, huh?

Of course, if you want to get more hands-on from the command line, you can also use bash shell scripts like the one shown in the Linux section earlier in this chapter, though the BeOS query function gives you the same functionality directly in the GUI, but without the need to edit configuration files.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint