This morning when I hopped on my home desktop machine, I was greeted with a nice iTunes error message telling me that my iPod was trying to sync with a library other than the one it was registered with. Huh?? A quick look at iTunes revealed the problem - it was completely blank! No songs, no podcasts, nothing. That's odd, because I have close to 30k songs I've ripped. I had a good idea what was wrong (but not how/why it happened). A quick look in my "My Documents\My Music\iTunes" directory revealed the problem. Both my "iTunes Music Library.xml" and my "iTunes Library.itl" file were only a few bytes each - when each of them should have been close to 50MB.

To make matters worse, I'm obsessed with meta-data. I have all of the album art and ID3 data for every single song - which is OK because the album art is stored in the directory for each album, and most of the meta-data is in the ID3 tags. BUT, because iTunes insists on using ratings outside of the ID3 tag format, all of the rating information I had accumulated (and associated smart playlists) was gone.

To top things off, I hadn't bothered to make a backup of my iTunes Library XML file lately because I'm running low on storage space. No excuse, I know.

Luckily, while I was looking in the iTunes directory, I noticed a sub-directory called "Previous iTunes Libraries". Inside that dicrectory were several copies of my "iTunes Library.itl" file. The most current one was about three months old - probably the last time I upgraded iTunes. Best case scenario I was looking at here was getting my library back, minus about three months worth of meta-data.

Getting iTunes to use the old .itl file was easy:

  1. Close iTuned
  2. Delete the blank/corrupted "iTunes Music Library.xml" and "iTunes Library.itl" files from "My Documents\My Music\iTunes"
  3. Copy the backup "iTunes Library.itl" file from the "Previous iTunes Libraries" directory to "My Documents\My Music\iTunes"
  4. Open iTunes - all of your music and meta-data up to the point of the backup file will be back.
  5. You'll need to add any music that you've gotten since the update. For me, that was easy. I just choose Add Music from Folder from the iTunes menu and chose the root directory where all of my music is stored. In about 10 minutes, iTunes had added all of the missing songs back to my library

There you have it. Relatively easy way to recover a deleted or corrupted iTunes library. Now if only I knew why iTunes decided to wipe it out in the first place.