I’m just getting back into scripting and I’m writing a few basic scripts to learn. The problem is that I am trying to do something that every other script example I’ve seen does easily, but mine doesn’t work? I’m hoping someone can pickup what I’m doing wrong.
My script currently allows a user to select a photo. This photo is then imported into iPhoto and a keyword is assigned. Note that I have added this keyword into iPhoto and assigned a few manually to make sure it works. I’ve even tried assigning a keyword of Birthday and that doesn’t work either?
set theFiles to choose file with prompt “select pictures to import” with multiple selections allowed
repeat with oneFile in theFiles
tell application “Finder” to set {theName} to {name} of oneFile
tell application "iPhoto"
try
import from oneFile
assign keyword string "New"
set thePhoto to (1st photo of last rolls album whose image filename is theName)
end try
end tell
set new_photo to choose file
set new_photo_pp to POSIX path of new_photo
tell application "iPhoto"
activate
import photo from new_photo_pp
set import_album to last import album
set imported_photo to first photo of import_album
select imported_photo
assign keyword string "New"
end tell
you can import multiple files at the same time with the import command.
It’s not necessary to coerce the paths, iPhoto accepts also alias specifiers
To assign the keyword you have to select the photos in iPhoto programmatically
set theFiles to choose file with prompt "select pictures to import" with multiple selections allowed
tell application "iPhoto"
import from theFiles
select photos of last import album
assign keyword string "New"
end tell