Batch processing a folder full of files in Photoshop


I have a script that tells Photoshop CS to batch process a large folder with files. When it is done I want the script to display a dialog saying “X” items have been moved to folder “Y”. How can I make the script wait for Photoshop to finish?

Thank you


If the script is timing out before Photoshop finishes then you should set a longer timeout period in the script:

with timeout of 3600 seconds
-- place your script here
end timeout

Adjust the number of seconds in the timeout to suit your needs.


It doesn’t appear that Photoshop has a busy flag so you have to make one. The following script assumes you are batch processing a folder full of files using an action saved as a droplet and kicked off by the Finder. It further assumes that Photoshop did not have a document open when it started and that the droplet action does not leave the documents it process open so that when it is finished processing all the images, there will again be no open documents. This script works by asking Photoshop for a reference to document 1. If it returns a reference, it is still processing files, if it return an error (no file open), it may be between files or it may be done. If it returns an error two times in a row it is probably done and the script continues. You may want to adjust the delay and timeout times as well as the paths to suit your needs:

set idle_check to 5 -- seconds
set start_time to (current date)
--tell ps to start batch processing by using a droplet...
set the_droplet to "path:to:droplet"
set the_folder to "path:to:folder of images:"
tell application "Finder"
    set file_count to (get files of (the_folder as alias))
    open {the_folder as alias} using (the_droplet as alias)
end tell
set should_continue to false
    delay idle_check
        with timeout of (2 * hours) seconds
            tell application "Adobe Photoshop CS" to get document 1
        end timeout
        set should_continue to false
    on error
        --this works so that it will continue if PS fails to have a document open two times in a row when the script checks
        if should_continue = false then
            set should_continue to true
            exit repeat
        end if
    end try
end repeat
set end_time to ((current date) - start_time - idle_check)
display dialog "It took about " & (end_time as string) & " seconds to process the " & (file_count as string) & " files of folder " & the_folder & "." buttons {"OK"} default button 1 with icon 1 giving up after 10