Saturday, February 10, 2007

iPhoto and Spotlight

I found out today that spotlight was not correctly indexing my iPhoto photos. I found this by wondering if Quicksilver's Set Comment... action would set the comment field of a photo in iPhoto. It turns out iPhoto's comment field is different than the Spotlight comment for the underlying file. Spotlight comments are stored in the metadata of the file, visible with the mdls command. iPhoto comments are stored in the ~/Pictures/iPhoto Library/AlbumData.xml file which is indexed specially by Spotlight. But I found that if I set an iPhoto comment, Spotlight wouldn't find it when searching. When I tried manually indexing the ~/Pictures/ directory (with mdimport) I got a parse error on the AlbumData.xml file.

This post on the Apple discussion boards explains it and describes how to fix things. It turns out that newlines in the iPhoto comments screw up the spotlight indexing. So I created a smart group of all photos with comments that contained a newline. I then went through the resulting 134 photos by hand and removed the newlines. Annoying, but it didn't take too long. I followed the rest of the instructions and had to delete the 3 slideshows I had saved (I could keep albums no problem). I added and removed a spotlight keyword to all 5500 photos in the Library. This remarkably took only a couple of seconds to perform.

Now everything works fine. But the iPhoto comments and Spotlight comments are still two separate things. It's a little inconvenient, but not a bug.

No comments: