The Mac mini I set up with Snow Leopard Server had previously been acting as a server using the client version of OS X. While I was setting up the server again after installing the Server operating system, I decided to also combine the existing external data drive with a second drive and make a RAID array. That meant reformatting both drives before they could be mapped as a RAID set. So I backed up my data (to a third drive) and then created the RAID set and copied my data back onto the new RAID drives.

I only realised some time later that I had used different names for the data partition before and after setting up the RAID array. So the iTunes library was full of little grey exclamation marks, indicating the track can no longer be found. If you double click on the track, iTunes will allow you to navigate to the new location of the music and will re-link the meta data in iTunes to the file containing the track. But with over 1000 albums and a lot of podcasts, that was not practicable:

The easiest way to fix the problem, that I am aware of, is to export the complete library as it is to your desktop.

How to export your library

This produces a file containing XML statements, however, you don’t need to be able to do more than identify your path to the tracks in this file. You need that because you are going to substitute the new path for the old one wherever it occurs. You can edit the XML file using, for example, TextWrangler and simply make a global replacement of the old path (up to, but not including the file name) with the new path. This might take several minutes – in my case the library file was 37 MB and that does take a time to substitute all the occurrences.

When the file has been edited and saved, you can import it into iTunes.

How to import the edited XML library file

The only small problem is that you will now have all your tunes listed twice, once with an exclamation mark and once without. However that is no big thing – you can eliminate the “wrong” tracks (with exclamation marks) by downloading and running the Super Remove Dead Tracks script from Doug’s Apple Scripts web site.

Being a script it is very slow, taking about 4 hours to run in my case. However, once it has finished its magic, you will have a clean iTunes library again.