I found a script on one of Apple’s pages that says it uses the new GUI scripting to get iPhoto to import images automatically. The script it gave was:
display dialog "Import an image file or a folder of images:" buttons {"Cancel", "Folder", "Image"} default button 3
if the button returned of the result is "Folder" then
set this_item to choose folder
else
set this_item to choose file of type {"JPEG"}
end if
-- convert the file reference to UNIX style
set this_path to the POSIX path of this_item
-- bring the target application to the front
tell application "iPhoto"
activate
try
tell application "System Events"
tell process "iPhoto"
-- summon the import dialog
click menu item "Import…" of menu "File" of menu bar 1
-- enter the path to the image in the dialog input
set the value of text field 1 of group 1 of group 2 of window "Import Photos" to this_path
delay 1
-- click to start the import
click button "Import" of window "Import Photos"
if the last character of (this_item as string) is ":" then
-- it's a folder so click the import button again
click button "Import" of window "Import Photos"
end if
end tell
end tell
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end tell
I can’t get this script to work, though, and I can’t figure out why. If I can get it to work, I need to change it a little bit. What I need to do is attach a folder action to a folder such that any pictures added to that folder would be automatically imported into iPhoto. Any suggestions?