I've recently upgraded to iPhoto '11 (couldn't resist the pricing on the new app store) and as I'm adding more meta-data to my library and generally organizing things (places, faces, etc... I hadn't upgraded since '08) I've noticed something odd in my photos. Every photo in my library has a description (though many are short), but it would appear that somehow the description of one of the photos has been appended to many.

I don't know if maybe I accidentally screwed up a batch change at some point in the past, or if the library upgrade somehow messed up, or what else may have happened. But what I need to do is fix these somehow.

Now, manually editing is something of a daunting task. Within a library of 21,248 photos, 18,858 of them have this additional text. The one thing I do have going for me is that it's a specific string. If there's a way to "remove this string from everywhere in the library without removing the rest of any given description" then that would be perfect.

Is there anything I can do like this? Maybe even manually editing a library file in a text editor? (Would that break anything else in iPhoto if its library was edited outside of the application, even while it's not running?) Does anybody have any ideas?

  • 1
    Here's where this info is stored: ~/Pictures/iPhoto Library/AlbumData.xml. If a photo has a description, it will be under the Comment key: <key>Comment</key> <string>testing description testing description</string> – Nathan Greenstein Jan 16 '11 at 15:23
  • @Nathan G.: Among other places, it would seem. I just tried opening that file in a text editor and replacing all occurrences, saving, and opening iPhoto. However, the text was still present in the photo descriptions. As I closed iPhoto, it re-wrote that file and the text was back. I also see the text present in a file called Properties.apdb, but when I tried to edit that iPhoto said the library had become corrupt and needed to be restored from backup (so I restored that file from a copy I'd made first). – David Jan 16 '11 at 16:02
  • 1
    @David - Nathan's suggestion is great. Try closing iPhoto, replacing the text, and then rebuilding the iPhoto library, by holding option while you launch iPhoto.. – Harv Jan 17 '11 at 18:50
  • 1
    @David - Oops. I meant cmd-option, not option. – Harv Jan 17 '11 at 18:55
  • @Harv: Didn't seem to work. I tried cmd-option when opening iPhoto after editing the XML file, which presented me with a few options for rebuilding the library. I kept the default, which is a "repair." But at the end of the repair, it said the library "was in use by another process" and had become unreadable. iPhoto exited, and upon re-starting it the text was still present. Thoughts? – David Jan 18 '11 at 1:35

Consider using an AppleScript to perform this task. The following AppleScript will get you started:

tell application "iPhoto"

    repeat with i from 1 to number of items in photos

        set myPhoto to item i of photos

        set comment of myPhoto to replaceText("find this", "replace with this", comment of myPhoto)

    end repeat

end tell

-- replaceText from Bruce Phillips (http://brucep.net/2007/replace-text/)
on replaceText(find, replace, subject)
    set prevTIDs to text item delimiters of AppleScript
    set text item delimiters of AppleScript to find
    set subject to text items of subject

    set text item delimiters of AppleScript to replace
    set subject to "" & subject
    set text item delimiters of AppleScript to prevTIDs

    return subject
end replaceText

To use this AppleScript, copy and paste it into a new AppleScript Editor document.

In this situation, you want to find and remove a specific piece of text. Modify the above AppleScript as follows:

  1. Change the "find this" segment and enter the text to find.
  2. Change the "replace with this" segment to be blank, "".

With these changes in place, save the document, and click Run in the toolbar. Depending on the number of photos, this AppleScript will take a long time; potentially hours.

  • I'd actually forgotten that I posted this question, thanks for reminding me! (Good thing SE has that unified inbox now.) I was originally looking for any approach to take, be it in the application's interface or through scripting. Turns out SO helped me out with the scripting a lot: stackoverflow.com/questions/4708418/… – David Feb 2 '11 at 23:21
  • Bruce Phillips's script does not work for me: Using iPhoto 11 v. 9.4.3, I get the error message "error "iPhoto got an error: Can’t continue replaceText." number -1708." – user50463 Jun 1 '13 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .