Hi everyone. This is a combo of a script of mine and a UI scripting script i found on Apple’s site for iPhoto. Everything seems to run fine except for inside the tell block for System Events, when it is supposed to set the value of the text field of the import photos sheet, it returns “System Events got an error: NSReceiverEvaluationScriptError: 4”. This part of the code comes directly from the Apple site’s example script. The only thing I changed was the declaration of “this_path” to the path that I want to use. Please help. This is with iPhoto 2.0 by the way, the most recent updated one with iLife '04. Here’s my script in it’s entirety.
set this_path to “/Volumes/NO NAME/DCIM/”
–import photos
tell application “iPhoto” to activate
tell application “System Events”
tell process “iPhoto”
– open import dialog
keystroke “I” using {command down, shift down}
– summon path input sheet
keystroke “/” using control down
delay 5
tell window “Import Photos”
tell sheet 1
set value of text field 1 to this_path
click button 1
end tell
click button 1
end tell
end tell
end tell
tell application “Finder”
–remove pictures from Treo
move the_treo to the trash
empty trash
–eject the Treo
set x to display dialog “Do you want to eject the Treo?” buttons {“NO”, “YES”} default button {“YES”}
if button returned of x is “YES” then
eject disk “NO NAME”
end if
end tell
sorry, feel free to ignore this post. I missed the part on apple’s page where it tells you how to turn on UI scripting, I guess when I updated to Panther I needed to turn it on again. Sorry. Haha.
I suspect the problem is that the folder you refer to does not contain any images, the images are contained in subfolders within this folder. That will not work.
What you need to do is gather all the images you wish to import in one folder, and then choose that folder.
or get a list of all subfolders, and then repeat this UI block for each subfolder, but that will create multiple import rolls in iPhoto.
also one tip; the way the script is from Apple, when importing this way, e.g. refering to a specific folder, the import “roll” will take the name of the folder (in your case “DCIM”) instead of being named roll 105 etc.
I’ve made a workaround for this:
tell application "iPhoto" to activate
delay 1
tell application "System Events"
tell process "iPhoto"
keystroke "I" using {command down, shift down}
keystroke "/" using control down
delay 1
tell window "Import Photos"
tell sheet 1
set value of text field 1 to import_path
delay 1
click button 1
end tell
end tell
click menu item "Select All" of menu "Edit" of menu bar item "Edit" of menu bar 1
tell window "Import Photos"
click button 1
end tell
end tell
end tell
this will import all photos from the folder you specify, but still get the numbered Roll names.