1 -- this sub-routine processes files 2 on process_item(source_file, new_name, results_folder) 3 -- NOTE that the variable this_item is a file reference in alias format 4 -- FILE PROCESSING STATEMENTS GOES HERE 5 try 6 -- the target path is the destination folder and the new file name 7 set the target_path to ((results_folder as string) & new_name) as string 8 with timeout of 900 seconds 9 tell application "Image Events" 10 launch -- always use with Folder Actions 11 set this_image to open file (source_file as string) 12 save this_image as JPEG in file target_path with icon 13 close this_image 14 end tell 15 end timeout 16 on error error_message 17 tell application "Finder" 18 activate 19 display dialog error_message buttons {"Cancel"} default button 1 giving up after 120 20 end tell 21 end try 22 end process_item