–This script will run sucsessfully 5 or 10 times then suddenly “variable this_image not defined” appears. Any thoughts or suggestions would be appreciated. Im running panther 10.3.2
property type_list : {“TIFF”, “JPEG”, “PNGf”, “PICT”}
property extension_list : {“tif”, “tiff”, “jpg”, “jpeg”, “png”, “pict”, “pct”}
property counter : “”
property paramList : {“”, “”, “”}
tell application “Image Capture”
quit
end tell
tell application “Finder”
activate
say “Please enter roll number”
set roll_number to display dialog “Enter Roll Number” default answer “xxxxxx-xx-xx” buttons {“OK”} default button 1
make new folder at folder “Original” of folder “Photo System” of startup disk with properties {name:“temp”}
set name of folder “temp” of folder “Original” of folder “Photo System” of startup disk to text returned of roll_number
set a to text returned of roll_number
select folder “Temp” of folder “Photo System” of startup disk
select every item of folder “Temp” of folder “Photo System” of startup disk
move selection to folder a of folder “original” of folder “Photo System” of startup disk
set nameheader to the text returned of roll_number & “-”
set counter to 1 as number
set mainList to "PhotoshopJPEG"
set listchoice to result as text
if listchoice is "PhotoshopGIF" then set paramList to {".gif", "GIFf", "8BIM"}
if listchoice is "PhotoshopJPEG" then set paramList to {".jpg", "JPEG", "8BIM"}
if listchoice is "PictureViewerGIF" then set paramList to {".gif", "GIFf", "ogle"}
if listchoice is "PictureViewerJPEG" then set paramList to {".jpg", "JPEG", "ogle"}
set fileext to text item 1 of paramList
set fileType to text item 2 of paramList
set creatorType to text item 3 of paramList
repeat with typeitem in folder a of folder "Original" of folder "Photo System"
try
if counter < 10 then set name of typeitem to nameheader & "0" & counter & fileext
if counter > 9 then set name of typeitem to nameheader & counter & fileext
set file type of typeitem to fileType
set creator type of typeitem to creatorType
on error errortext
display dialog "An error has occured with file: " & typeitem & " :- " & errortext
end try
set counter to counter + 1
end repeat
open folder a of folder "original" of folder "Photo System" of startup disk
select folder a of folder "original" of folder "Photo System" of startup disk
copy selection to folder "inhouse" of folder "Photo System" of startup disk
say "please wait while images are resized, this may take a few minutes"
end tell
tell application “Finder”
try
set the source_folder to folder a of folder “inhouse” of folder “Photo System” of startup disk
set these_files to every file of the source_folder whose file type is in the type_list or name extension is in the extension_list
repeat with i from 1 to the count of these_files
set this_path to (item i of these_files) as string
tell application “Image Events”
set this_image to open file this_path
scale this_image to size 1280
save this_image
close this_image
end tell
– FINDER ACTIONS SUCH AS MOVE, DUPLICATE, OR DELETE GO HERE
end repeat
on error error_message
display dialog error_message buttons {“OK”} default button 1
end try
end tell
tell application “Finder”
select folder a of folder “inhouse” of folder “Photo System” of startup disk
copy selection to folder “temp” of folder “Photo System” of startup disk
try
set the source_folder to folder a of folder "temp" of folder "Photo System" of startup disk
set these_files to every file of the source_folder whose file type is in the type_list or name extension is in the extension_list
repeat with i from 1 to the count of these_files
set this_path to (item i of these_files) as string
tell application "Image Events"
set this_image to open file this_path
scale this_image to size 450
save this_image
close this_image
end tell
-- FINDER ACTIONS SUCH AS MOVE, DUPLICATE, OR DELETE GO HERE
end repeat
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
select folder a of folder "temp" of folder "Photo System" of startup disk
move selection to folder "ftp" of folder "Photo System" of startup disk
close every window
eject disk "NO NAME "
say "Transfer is complete. please remove the compact flash card now"
end tell