Cesare Asaro
Cesare Asaro

Reputation: 5

How to pass a list/array of file paths from AppleScript to a Photoshop Droplet

I’m trying to pass a dynamically generated list of file paths to a Photoshop (PS) droplet for processing.

I got most of the way but I’m stuck as the Photoshop droplet only processes one of the files that gets handed off.

  1. The file are dropped on the AppleScript app.
  2. The files are renamed and then moved to a new directory
  3. Step 2 will generate a list of the paths for the files
  4. The list of paths should be processed by the Photoshop Droplet in its entirety

The image files are quite large (above 1GB) and each will require some time to be processed, that’s why I decided to place the PS Droplet processing as a final step of the AppleScript. Originally I was trying to drop one file at the time on the PS droplet but the AppleScript processes the files faster than the PS droplet, leaving me with just one image done. I couldn’t find a way to pause the AppleScript until the javascript in the PS droplet was complete.

This is what the Scrip Editor recorder when I dropped 2 file on the PS droplet. I tried to concatenate each string in the list with the same syntax but I was unsuccessful.

tell application "Finder"
    activate
    open {document file "2024_03_27_01_M.tif" of folder "Test 2 copy" of folder "Scan" of folder "Scans" of disk "VIDEO-REC", document file "2024_03_27_02_M.tif" of folder "Test 2 copy" of folder "Scan" of folder "Scans" of disk "VIDEO-REC"} using application file "Scan_Preview.app" of folder "Scans" of disk "VIDEO-REC"
end tell 

I’ve tried:

  1. passing on the list of paths as alias
  2. passing on the list of paths as string
  3. passing on the list of paths as hfs paths
  4. building a list with “document file “ built in for every item in the list
  5. I have no idea how to do it with a “ do shell script”

At best case scenario I’m only able to have only one files processed by the PS Droplet.

I have spent quite some time looking and trying multiple alternative but I’m at a loss.

This is what I have in the testing script at the moment:

property imagesForDroplet : {} #list of items to process with Photoshop Droplet
property toPsDroplet : "/Volumes/VIDEO-REC/Scans/Scan_Preview.app" # location of the PS Dropplet 

on open (theFiles)
    delay 0.1
    activate
    
    
    set i to 1
    repeat with aFile in theFiles
        
        set newFilePath to aFile -- just a place holder for the new file directory
        set the end of imagesForDroplet to newFilePath as string
        
        set i to i + 1
    end repeat
    choose from list imagesForDroplet
    
    
    tell application "Finder"
        activate
        set toPsDropletHFS to POSIX file toPsDroplet as string
        open document file imagesForDroplet as alias using application file toPsDropletHFS
    end tell
    
end open

Any help would really be appreciated.

Upvotes: 0

Views: 41

Answers (0)

Related Questions