Applescript- How do I use a List to Select Specifc a Photoshop Action

Hi,

wondered if anybody could give a few pointers on a script i’m writing

Aim
I want to use a list to extract different cobinations of files* from a defined folder, I would then like that same list selection to choose between mutliple photoshop actions and run the extracted file combination through that action.
*extracted files have a standardised naming convention

Current Issues

-getting the returned list selection to run the photoshop action

-how to repeat the action on multiple images.

Project Breakdown

Stage 1
-on opening run a list

-List to conatain a set of names relating to photoshop actions

-select action name from list

Stage 2
-choose folder with source images (always 14 images always with the same last 9 characters _0000.tif to _0013.tif)

-Choose a save folder

Stage 3
-dependant on original list selection, gather files from source image folder and run them through a coresponsing photoshop action

e.g If “Action 1” selceted from List select image “_0001.tiff & _0010.tif” from source folder and do photoshop action “Action1”

Stage4
-save in chosen “save folder”

Current Script

--Stage 1--

set PhotoshopActionList to {"Action1", "Action2", "Action3", "Action4", "Action5"}

set ActionrequiredAnswer to choose from list PhotoshopActionList with title "Actions Picker" with prompt "Choose Action?"


if ActionrequiredAnswer is false then
    error number -128 (* user cancelled *)
else
    set ActionrequiredAnswer to ActionrequiredAnswer's item 1 (* extract choice from list*)
end if

end run

--Stage 2--

property SourceFolder : missing value
property destinationFolder : missing value

if SourceFolder = missing value then
    set SourceFolder to (choose folder with prompt "Choose Base Images:")
    set destinationFolder to (choose folder with prompt "Choose Save Location:")
else

    tell application "Finder"
        set theFolders to every item of entire contents of SourceFolder as list
        repeat with thisFolder in theFolders
            make new alias file at destinationFolder to thisFolder
        end repeat
    end tell
end if

--Stage 3--

tell application "Finder"
    set filesList to {files of entire contents of SourceFolder contains "_001", "_002", "003"} as alias list
end tell

tell application "Adobe Photoshop"
   repeat with aFile in filesList
       open aFile

       do action "Action1" from "Actionsfolder"
end tell

--Stage 4--

save currentDocument in folder destinationFolder as JPEG

Thanks

Running the action is just calling the action name from the action set like this:


tell application "Adobe Photoshop"
do action "YOUR_ACTION" from "YOUR_ACTION_FOLDER"
end tell

So the easiest way to do this would be to have all the actions in one action set, then have the names in the list the user chooses from be the exact names of the actions in Photoshop and you can just use the “text returned” in your “do action” line.

Alternately, you can use different names for the actions in the script and then translate.

Doing it this way will require script changes any time you change the available actions. If you want to get fancy with it, you can use a “do javascript” to read the names of the actions in a set and then use that to generate the “choose from list” in Applescript, so you can change the actions around any way you like in Photoshop, and the script will always be correct/current.

https://forums.adobe.com/thread/591215

Repeating the action on multiple images is just something like this:
open the images

tell application "Adobe Photoshop"
	set allDocs to every document
	repeat with aDocument in allDocs
		set the current document to aDocument
		do action "YOUR_ACTION" from "YOUR_ACTION_FOLDER"
	end repeat
end tell

This is brilliant!! Thanks, I like the idea of adding some Java Script in there as well so definetly something to i will develop!