August 20, 2009

Stupid hard drives. Stupid iTunes.

Spent five or six hours last night trying to resurrect my iMac. Well, wrong word - the iMac was fine. I'd lost my external drive with my backup and my iTunes library. Don't care about the former, so long as I can get a backup on the replacement without anything happening to the Mac, but the latter..yeah.

I had a backup of the media directory on my server, but due to perms craziness, the automatic rsync update no worky and I'd been doing it when I remembered to. The 'last modified date' on the backup tree was 5/9/09, which wasn't too bad - but I discovered while looking that in fact the most recent actual file synced to the backup was from 10/8/2008. Guh. So everything I've put into iTunes since then - *pffft*.

Worse yet - I couldn't get iTunes to find the restored files. The problem was that since they had lived on a separate volume, the path my iTunes library DB was set to reflected that. However, iTunes lets you change the path to the library, right? Okay. So I copied the rest of my library back into a local directory, and changed the library location.

Nope. Couldn't find the files. Even through they were there. When I clicked a file, it would give it the '!' mark and give me the message ("Do you want to locate it?") When I located it, it was right where the prefs file said it should be, and then it would play - but I have over 18K items in my library. Even after the loss. Not viable.

Okay, time to make a backup copy of my iTunes library directory (the databases, not the media) and start fucking around. BBEdit let me open iTunes Library.xml. In there, I found both the prefs setting for the library location and the listings for all the tracks. Interestingly, the library location was *different* from the path in all the track entries - and the track entries' paths were all set to the 'default' of ~/Music/iTunes/iTunes Music. Lovely.

Okay. Changed all the paths of all the entries using grep. Saved. Restarted iTunes.

Nope. Apparently, the XML file is an *export* - the controlling file is the iTunes Library.itdb or whatever, which is a binary database file. Fuckers.

After a couple of hours, I determined that if I moved all the files into the actual ~/Music/iTunes/iTunes Music/ path, and then changed the prefs in iTunes to reflect that, it would in fact find the music. Why it wouldn't find it if I put the music anywhere *else* and changed the prefs to point *there,* I have no idea - but I have a guess; I'll guess that since the file loc paths in my XML file didn't agree with the library location pref, I'm going to guess that iTunes was not or was refusing to properly update the file locations when the location pref was changed - maybe because it was already screwed - i.e. they didn't match.

I don't know how that happened, but I can guess - I'm going to guess that when my original drive died, my Mac (which was running at the time) did *something* involving iTunes (I may even have left it open) and when it realized it couldn't see the volume the library was set to, it changed all the file paths back to the default location - even though the files weren't there. That library file was the one I was still using - because my backup of the library database had been on the other partition of the dead drive, in the backup volume.

Fuck fuck fuck.

So anyway, after moving everything back into the 'default' location, iTunes found it all.

At which point I can determine that 353 items that *had* been in my library no longer exist, although their DB entries still do. Ah well, at least I have a chance to go re-acquire all those tracks and re-enter them, since their data is still there - playcounts, ratings, playlist inclusion, etc. And looking at them, I know that at least 200 of 'em are tracks I *got* but never played with, so meh.

Posted by jbz at August 20, 2009 2:11 PM | TrackBack

Post a comment

Remember personal info?