1

Ive been trying to write a Applescript using the bits of knowledge I have

current stumbling blocks are

-getting the returned list selection to run the photoshop action

-how to repeat the action on multiple images.

Aim I want to use a list to extract different cobinations of files (with set naming conventions) 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.

Stage 1 -on running open a list

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

-select 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, automatically 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"

The Script So Far

--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
JdG
  • 27
  • 5
  • "I'm struglling to pull all the core areas together" - can you please [edit your question](https://stackoverflow.com/posts/53250511/edit) to clarify where the stumbling block is exactly? – cybernetic.nomad Nov 11 '18 at 16:18
  • Thanks for replying, updated, should be a bit clearer what im struggling with now, – JdG Nov 11 '18 at 16:41

1 Answers1

0

I did not found a way to select entire contents of folder AND filter extension 'tif', 'tiff',.. AND filter files whose name contains your patterns.

As work around, I did 2 steps:

1) select in entire contents only files with target extensions.

2)I loop through these files to check is file name contains the target pattern. This is done by routine FnameOK.

You need to complete the script bellow with your Photoshop action and the 'save as':

set PhotoshopActionList to {"Action1", "Action2", "Action3", "Action4", "Action5"}
set ListOK to {"_001", "_002", "003"}
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

set SourceFolder to (choose folder with prompt "Choose Base Images:")
set DestinationFolder to (choose folder with prompt "Choose Save Location:")

tell application "Finder" to set filesList to files of entire contents of SourceFolder whose name extension is in {"tiff", "tif"}

repeat with aFile in filesList
    tell application "Finder" to set NameF to name of aFile
    if FNameOK(NameF, ListOK) then -- the file name contains a valid pattern, then process the file
        tell application "Adobe Photoshop" 
            open (aFile as alias)
            -- perform action selected
            -- save as to Destination Folder
        end tell
    end if
end repeat

on FNameOK(Local_Name, LocalList) -- check if the file name contains an element of the list
    set LocalCheck to false
    repeat with OneItem in LocalList
        if Local_Name contains OneItem then
            return true
        end if
    end repeat
    return false
end FNameOK
pbell
  • 2,965
  • 1
  • 16
  • 13
  • Hi, Thanks for the reply, I've just tried the script a and its getting stuck when creating the alias list? Ive tried changing this from an alias list to just a list but then gets stuck when setting the NameF. Any ideas of help much appreciated. Thanks J – JdG Nov 12 '18 at 08:49
  • This script is perfectly working on my mac. The only difference is that I am calling "Adobe Photoshop CS3" because I have an old Photoshop version. But is does not impact the list of files. Are you sure you have used same syntax as in the script ? what is your error ? which line ? (note, of course, if you change the syntax I used you get the list of alias, you may not longer get alias...then next instruction will failed. – pbell Nov 12 '18 at 15:17
  • thanks again for the reply I'm getting the below error error "Can’t make every file of «class ects» of alias \":Users:User:Desktop:Base Image Folder:\" whose name extension = {\"tiff\", \"tif\"} into type alias list." number -1700 from every file of «class ects» of alias ":Users:User:Desktop:Base Image Folder:" whose name extension = {"tiff", "tif"} to «class alst» Thanks J – JdG Nov 12 '18 at 16:06
  • Sorry, my mistake. I have incorrectly copy my script. The line is now updated, as well as open line. – pbell Nov 12 '18 at 18:06
  • This is Brilliant, Thank you so much for your help!! – JdG Nov 12 '18 at 20:27
  • Soooo, I’ve been using the above with lots of success (thanks again) and wondered if there was an easy way to add additional item to the lists that then calls out multiple list options, e.g add “action 4” that then runs through “actions 1” & “action 2” I’ve been playing around with a solution but it’s lengthy with repetition and I’m sure there’s a smarter way, Thanks – JdG Nov 27 '18 at 19:48
  • Yes possible. add the 'with multiple selections allowed' at end of the 'choose from list ' instruction. this will allow multiple selections like actions 1 and 3. Then, after the 'open file', instead of the 'perform action, just loop (repeat / end repeat through actions selected and perform each one. – pbell Nov 27 '18 at 22:20