(* To work, this script requires Panther with Folder Actions and GUI Scripting enabled. To turn on, click "Enable access for assistive devices" in the "Universal Access" preference pane. Place this in "Library/Scripts/Folder Action Scripts" and enable it as a Folder action for "/Volumes" (you can get to "/Volumes" by "Go to Folder" from the Finder's "Go" menu). This takes some hints from Apple's GUI Scripting example page at http://www.apple.com/applescript/uiscripting/03.html, and Apple's Folder Action Scripting example page at http://www.apple.com/applescript/folderactions/05.html. *) property eject_when_done : true property erase_when_done : false property confirm_import : false property theName : "DIMAGE_X20" property theSource : "DIMAGE_X20:DCIM:100MLT19" property theDest : "Macintosh HD:Users:ben:Pictures:iPhoto_temp" property movieFolder : "Macintosh HD:Users:ben:Movies" on adding folder items to this_folder after receiving added_items tell application "Finder" activate try repeat with i from 1 to number of items in added_items set this_item to item i of added_items if the name of this_item is theName then set this_disk to (this_item as alias) if confirm_import is true then display dialog "Import pictures?" giving up after 30 if the button returned of the result is "" then error number -128 end if tell application "Finder" move (every file of folder theDest whose name extension contains "JPG") to trash if erase_when_done is true then move (every file of folder theSource whose name extension contains "JPG") to theDest move (every file of folder theSource whose name extension contains "MOV") to movieFolder else move (every file of folder theSource whose name extension contains "JPG") to theDest move (every file of folder theSource whose name extension contains "MOV") to movieFolder end if end tell delay 1 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 1 tell window "Import Photos" tell sheet 1 set value of text field 1 to "/Users/ben/Pictures/iPhoto_temp/" delay 1 click button 1 end tell delay 1 click button 1 end tell end tell end tell delay 1 if eject_when_done is true then eject this_disk end if end if end repeat on error error_message number error_number if the error_number is not -128 then display dialog error_message buttons {"OK"} default button 1 end if end try end tell end adding folder items to