Disclaimer: I’ve read every post in here with the word iPhoto, read the Apple Applescript reference (several) times, and looked at every iPhoto script available online.
What I’m trying to accomplish is to assign a keyword to each photo for the album it is in.
For the sake of simplicity, I’m just trying to get it to function. My test library has a few albums and a dozen photos, each album title is already a defined keyword, and each image only appears in a single album, so there shouldn’t be an issue with lists, multiple matches, or making new keywords.
tell application "iPhoto"
activate
set photo_list to selection
repeat with i from 1 to the count of the photo_list
set current_photo to item i of the photo_list
set album_name to the name of the album of current_photo
assign keyword string album_name
end repeat
end tell
If I run that, I get “iPhoto got an error: Can’t make name of album of photo id 4.294894E+9 into type reference”
if I change the middle line to
set album_name to the name of the album of current_photo as string
, then it returns “Can’t make name of <> of <> id 4.294894E+9 of application “iPhoto” into type string”
Reading through the apple Applescript docs, I thought it might be a unicode issue, so I changed everything from strings to Unicode text, and get the same result (of course with type Unicode text on the errors).
At this point I’m sure I’m missing something glaringly obvious. I think I’m pulling the name of the album as a simple string, but clearly I’m either completely wrong on what i’m doing or I’m completely wrong in what the data looks like. The name of the albums are “bob”, “tom”, “stephanie”, and similar, nothing exotic that i’d expect to cause issues.
I’d appreciate if someone could point out the error I’m making in my logic, syntax or whatever!
thanks
nathaniel