Sunday, July 16, 2006

iTunes problem solved!

I have been pretty pleased with the new Lenovo ThinkPad T60p I was issued with a few weeks back. It's bigger and heavier than I would like but I'll live with that.

However, when tranferring my files and settings from my old laptop, I managed to mess up iTunes. About one track in two that I tried to play would fail and iTunes would issue a message that said: "[name of song] could not be used because the original file could not be found". The irritating thing was that the file was on the disk and, if I pointed iTunes at it, it would work. What was going on?

I ignored the problem for a while until I decided to fix it this morning (being crippled, there was not much else I was good for this morning).

A search for the error message turned up lots of scary postings on message boards suggesting my iTunes database was in some way corrupt.

Thankfully, it was nothing so serious: I store all my music in the "My Music" folder of "My Documents" and iTunes keeps track of all the files through its "iTunes Music Library.xml" file. A quick glance through this file showed the problem: I am using a different user ID on my new system and so the "My Documents" folder has a different location... iTunes was telling the truth after all!

My first inclination was to edit the file. So I pulled up the documentation for sed and did a global search and replace on the file. No joy.... iTunes was still complaining. A further search of the web provided the problem: iTunes actually reads a binary representation of the XML file ("iTunes Library.itl").

The recommendation was to corrupt this file so that iTunes is forced to rebuild it from its XML file. The side effects (lots of meta-data gets lost) were more than I was prepared to accept so I reinstated the original file and employed a hack:

I created the missing directory and copied all my music files into it so that they were now were iTunes was expecting. Result.

No comments: