How to get iPhoto '08 events

Hi all,

since iPhoto '08 is using events now to organize photos I would like to get some event information via applscript. I know that I can get every album by this script:


tell application "iPhoto"
	set albumList to name of every album
	set albumNo to count of albumList
	repeat with i from 1 to albumNo
		set albumName to name of album (item i of albumList)
		display dialog albumName
	end repeat
end tell

But I would like to get the “event” of the selected image. Something like:


set eventName to the name of the event of currentPhoto as string

Regards, Alex

Alex:

There isn’t a direct way via AppleScript to get Event names, but they are present in the image path for a given photo and can be extracted thusly:


tell application "iPhoto"
    set a to image path of photo 666
end tell

GetEventName(a)

to GetEventName(b)
    set astid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "/"
    set event_string to b's text item -2
    set AppleScript's text item delimiters to astid
    return event_string
end GetEventName

-->"Jan & Feb 2007"

This also works immediately upon changing the name of an event in iPhoto, so it can be run fearlessly. Of course, if you have an event name like Spring/Summer 2007, your result will be screwy:

"Spring:Summer 2007"

Good luck,

Thank you a lot Craig! You just got some credits in my script :wink:
I’m working on one to sync iPhoto '08 with EXIF/IPTC/XMP meta data in the files. There are a little number of such scripts but no satisfying one. Maybe I’ll post it here later on.

I am looking to get the event names as well. I have seen some apps (Comic Life) that provide these names quickly, so I am wondering if this is available at another level (not applescript).

Would it be possible to get this information any other way?

Or, is it possible that this will be added to iPhoto in the future either by a maintenance release, or new version?

Thanks for your help