April 12, 2006

A possible fix when iTunes can't sync your iPhoto library

In the spirit of writing for Google, here's a possible fix for when iTunes can't sync your photo library. Recently, whenever I tried to sync my iPod Video (60 gig), I'd get the cryptic error message "...An error occurred (-50)". I discovered that this was due to the photo syncing; iTunes was having problems reading my iPhoto library.

You can tell that this is the case by plugging in your iPod and going to iTunes' iPod preferences. When you click on the photo tab, if "iPhoto" is selected in the "From:" popup menu but the album list is blank, then you're probably experiencing the error I did.

I turns out that the error was caused because one of my photos had a null character in its caption. (How I accidentally typed that illegal character, I have no idea.) So how would one identify which of the thousands of photos is causing the problem? What I did is copied my ~/Library/Pictures/iPhoto Library/Album Data.xml file to my desktop, renaming it to "Album Data - zapped.xml". I then loaded it in BBEdit and chose Text > Zap Gremlins… In the dialog that pops up next, it is very important to uncheck "Non-ASCII Characters", or else it'll detect any curly quotes, etc. as gremlins, which you don't want. Leave both "Control Characters" and "Null (ASCII 0) Characters" checked, though. Also, have it Delete the zapped characters, which is the default. Then click on Zap.

Now that you have the zapped file, save it and choose Search > Find Differences… Compare the original file (still in ~/Library/Pictures/iPhoto Library/) to your new, zapped file. In my case, I found one entry, which I knew to be the offender. I went into iPhoto, rewrote the caption (this time sans any illegal characters), and voila, the problem was fixed. (You can confirm that it's fixed by revisiting the Photos tab in the iTunes preference: if your albums are now listed, you're good to go. Note that if you're running iPhoto 5 or lower, you'll have to quit iPhoto first in order for it to write out the updated Album Data.xml file before going to the iTunes preferences.)

Anyway, this worked for me, so if you're having the problem, too, hope it helps!

This computer tip was posted at 06:05 PM