I have this Photoshop script that has a bunch of handlers to do certain things when certain parameters of an image are met. I have now been asked to have this script repeat itself x number of times from the user.
set target_size to text returned of (display dialog "Enter target size of longest side in pixels:" default answer 400)– set general variables of folder locations
set raw_folder to choose folder with prompt “Select originals folder:”
set live_folder to choose folder with prompt “Select target folder:”
– GIFs or PNGs
display dialog “Do you want to make GIFs or PNGs?” buttons {“GIF”, “PNG”}
set buttonAnswer to button returned of result
if buttonAnswer is “GIF” then
set transparancyType to convertGIF
– a subroutine that send the resulting image into the target folder (live_folder)
else if buttonAnswer is “PNG” then
set transparancyType to convertPNG
– a subroutine that send the resulting image into the target folder (live_folder)
end if
tell application “Finder”
– make an item list from your identified folder
set itemList to files in raw_folder
end tell
– create a repeat that takes each file from the item list and do something
repeat with i from 1 to count of items of itemList
tell application “Finder”
set fileName to (item i of itemList) as string
–set itemPath to raw_folder & fileName
end tell
-- reset the defaults to Photoshop
tell application "Adobe Photoshop CS5"
set display dialogs to never
activate
open alias fileName
if (count of path items) of current document = 0 then
tell application "Finder"
set noError to true
end tell
try
trim current document basing trim on transparent pixels
on error
tell application "Finder"
set noError to false
end tell
end try
if noError is true then
--display dialog "you can make this a GIF" giving up after 3 and flag
tell application "Finder"
set label index of alias fileName to 2
end tell
tell current document
try
close saving no
end try
end tell
else if noError is false then
my convertJPEG(target_size, live_folder)
-- a subroutine that send the resulting image into the target folder (live_folder)
end if
else
get (kind of path items) of current document
set pathList to result
set numPath to count pathList
-- there is a clipping path
if (numPath ≥ 1) and ¬
pathList contains {clipping} then
--convert and save to GIF or PNG
my transparancyType(target_size, live_folder)
else if (numPath ≥ 1) then
-- set the label color to red because no clipping path has been defined
tell application "Finder"
set label index of alias fileName to 2
end tell
end if
end if
tell current document
try
close saving no
end try
end tell
end tell
end repeat
</The Script>
How can I get this to start off with something like:
set number_of_sets to text returned of (display dialog “How many sets of images are we making?” default answer 3)
repeat with i from 1 to count of items of number_of_sets
</The Script>
but then have it designate x number of destination folders with a x variable size?
The raw_folder remains the same.
Sorry for the Noobie question