I would like to thank Nigel for the info that allowed me to build the engine of this script, I have expanded its scope slightly, and now I have run into some interesting issues. First off I know that it could be greatly simplified with some function calls and repeat untils, but I am still figuring that out. So in the mean time I hand looped this stuff, and it works great for the first three folders and then errors out saying “Can’t make some data into the expected type”. Not sure why and it does not matter what folder is there it errors out in the midst of the third cycle. Any suggestions. Thanks so much.
property extension_list : {"tif", "tiff", "jpg", "jpeg", "eps", "psd"}
property type_list : {"TIFF", "JPEG", "PNGf", "PICT", "EPS", "PSD"}
try
tell application "Finder"
set the myFOLDER to choose folder with prompt "Pick a folder containing the images to process:"
try
if name of myFOLDER is "Links" then
set source_folder to myFOLDER
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
-- Create the "thumb" folder if it doesn't exist.
if (folder "thumb" of desktop exists) then
set thumb_folder to folder "thumb" of desktop
else
set thumb_folder to (make new folder at desktop with properties {name:"thumb"})
end if
repeat with i from 1 to the count of these_files
-- Get the path to this image file.
set this_path to (item i of these_files) as Unicode text
-- Duplicate the file to the "thumb" folder and get the path to the result.
set new_path to (duplicate file this_path to thumb_folder with replacing) as Unicode text
close source_folder
end repeat
else
open myFOLDER
set allFOLDERS to every folder of myFOLDER
repeat with i from 1 to count of allFOLDERS
set l2FOLDER to item i of allFOLDERS
if name of l2FOLDER is "Links" then
activate l2FOLDER
open l2FOLDER
set source_folder to l2FOLDER
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)
-- Create the "thumb" folder if it doesn't exist.
if (folder "thumb" of desktop exists) then
set thumb_folder to folder "thumb" of desktop
else
set thumb_folder to (make new folder at desktop with properties {name:"thumb"})
end if
repeat with i from 1 to the count of these_files
-- Get the path to this image file.
set this_path to (item i of these_files) as Unicode text
-- Duplicate the file to the "thumb" folder and get the path to the result.
set new_path to (duplicate file this_path to thumb_folder with replacing) as Unicode text
close source_folder
end repeat
else
open l2FOLDER
set allL2folders to every folder of l2FOLDER
repeat with i from 1 to count of allL2folders
set l3FOLDER to item i of allL2folders
if name of l3FOLDER is "Links" then
activate l3FOLDER
open l3FOLDER
set source_folder to l3FOLDER
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)
-- Create the "thumb" folder if it doesn't exist.
if (folder "thumb" of desktop exists) then
set thumb_folder to folder "thumb" of desktop
else
set thumb_folder to (make new folder at desktop with properties {name:"thumb"})
end if
repeat with i from 1 to the count of these_files
-- Get the path to this image file.
set this_path to (item i of these_files) as Unicode text
-- Duplicate the file to the "thumb" folder and get the path to the result.
set new_path to (duplicate file this_path to thumb_folder with replacing) as Unicode text
close source_folder
end repeat
end if
close l3FOLDER
end repeat
close l2FOLDER
end if
close allFOLDERS
end repeat
end if
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end tell
end try