Making Sense of iTunes Storage

One ordinarily does not need to know how Apple’s iTunes stores its tunes. The exceptions are when one wants to retrieve a digital track from iTunes, or when one wants to go down-level with a library (to host under a prior version of iTunes), in my case satisfying a retro-computing habit.

I use iTunes 9.2.1 as my base version. I was able to find this Macintosh version for download on the Internet, and it will run under Tiger, the earliest version of OS X that I am still comfortable running. Panther users can still download iTunes 7.7.1. iTunes 7.7.1 lacks the grid view GUI niceness, but otherwise is entirely functional as a server of tunes.

My library is created from ripped CDs (no iTunes store purchases), so can be stored using 100% Apple Lossless Compression (ALC or ALAC). Hence, each digital track is stored in an MPEG4 wrapper, a file with .m4a suffix. The standard location for iTunes music storage is: /Users/username/Music/iTunes/iTunes Music. One can host the library elsewhere, say on an external volume, by choosing a different path in the iTunes/Advanced preference pane.

Within this library folder, tracks are stored in a three-level folder hierarchy: artist:album:tracks; all are named sensibly for easy recognition. It is thus simple to retrieve an individual track for export or external processing.

There is an index file built/extended whenever loading new music into iTunes; this index is also exported to an external file: iTunes Music Library.xml. The server or playback software will use the library index to locate a requested music track. When one migrates to a new version of iTunes, all library tracks are automatically reloaded to create a new index (if a different format as required by the new iTunes version). The same will be true when migrating to a prior version of iTunes. One manually throws away the current index and explicitly ‘loads’ one’s library, to build a new index. After that, all should be working perfectly, including Playlists. All, that is, except one’s album art. Going forward in version, Apple handles migration of art. Going backward in version however can result in much collected album art becoming disassociated with the library.

Album art is stored in a folder Album Art within the iTunes folder. It can have subfolders for different uses, such as Cache, Download, and Local. Within each are a hierarchy of folders named with 4-bit numbers 0-15. At the end of each nesting is a graphics container file with .itc suffix. Each .itc file consists of some header data followed by an embedded graphic, mostly in either .jpg or .png format.

Thus all music album art is accessible, but some of it becomes disassociated, while some of it remains accessible. The reason is not clear to this investigator. But clearly, it will be easier to extract the art from these files if possible, rather than locating the missing/disassociated art all over again on the Internet. Then, each image must be manually reattached to the corresponding library album.

There is a freeware Java program from Sourceforge called AlbumArtExtractor that removes the ,jpg images from their .itc containers. Unfortunately, it leaves the graphics file within a similar non-descriptive hierarchy of folders with numerical names, making access hugely inconvenient. So one needs the help of Unix to flatten this folder hierarchy and collect all the .jpg files in a single folder called art within the Album Art folder. Enter the following commands in Terminal app to put all the extracted images in a single folder called art, where directory albumArt contains the file folder hierarchy containing the extracted images, by default ~/Desktop/albumArt:

cd albumArt
mkdir art
cd albumArt # 2nd nested folder created by AlbumArtExtractor
find . -name ‘*.jpg’ | xargs -I{} cp \{\} ../art

There may be some .png files for embedded artwork as well, so a repeat of the command with .png rather than .jpg should extract these as well. The files in the art folder will all have long nonsense hyphenated alphanumeric names with first part the internal id of the library and second part the id of the .itc file containing the graphic. I use a graphics browser such as the free ViewNX from Nikon to display the artwork at full screen size. Then, each filename can be renamed appropriately so that the file list will sort into the same order as the albums appear in iTunes. This makes it easy to manually reinsert each missing graphic into the down-level iTunes library structure.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s