Photoshop Automation via JavaScript


This is a utility script to run other scripts.   It addresses a frustrating restriction in CS2 where files selected in the Bridge cannot be processed easily in Photoshop.   It enables Photoshop workflow automation directly from Bridge selections.

This uses an unused function from the ImageProcessor, GetFilesFromBridge.   With it you can make a selection of one or more thumbnail images in the Bridge, then from Photoshop run this script.   It will in turn run user selected scripts and actions against all the files in the selection.   A sample menu follows:

The Cancel button simply exits the script.   The OK button will run the currently selected scripts and actions for each image currently selected.   If the Bridge is not running or the currently selected files are not image files, the script will exit with a message, but without the dialog.   If the Bridge is running, but there are no files selected, all image files in the current Bridge folder will be selected.   This is a Photoshop anomaly that cannot be easily addressed by anyone but Adobe.

The display of the selected folder and list of files are merely for your review and validation.   They cannot be changed here.   Folder names and non-image files are automatically removed from the file selection list.   The script path and number of available scripts is also merely for your review.

The Open Files check box will iterate a file open before the selected script is executed.   Most user scripts would expect the image to be opened before it executes.

The Wait for Redraw option will allow Photoshop to refresh the screen after each script or action.   The batch will run faster without this option.

The lists of available Scripts are selectable.   If "none" (the first item) is selected, no script will be run.   The Action Sets and Actions are also selectable.   If "none" is selected for the Action, nothing will be run.   All scripts are run in the order shown.   That is, script one, script two, action one, script three, action two, script four, then script five.

The default Close Option is "none".   In many cases the last target script or action will perform any desired save and close operations.   If not, this option will leave the file open.   The "discard" option will close the image without saving any changes.  

The default Target Folder is a "new" sub folder below the currently selected image folder.   It will be automatically created if it does not exist.   The Choose button may also be used to select an existing folder. If a File Name Prefix has been entered the image will be saved with a new file name and default Photoshop save options for the current file type (extension).   If a Sub-Folder is specified, it will be created below the current folder for the selected images, if it does not already exist.   The images will be saved in this folder.   So you can rename the images via the File Name Prefix option, save them in a new folder, or both.

Other Close Options include Save as JPG, Save as PSD, and Save as TIF.   If Save as JPG is selected, additional options to specify the JPG Quality and Convert the color space to sRGB are enabled.

There are some configuration variables at the beginning of the script.

   // ======================================
   // Configuration Variables
   // ======================================
   var gffbShowDialog = true;                      // run silent?
   var gffbOpenFiles = true;                       // open selected files?
   var gffbScriptToExecute1 = "none";              // user script 1?
   var gffbScriptToExecute2 = "none";              // user script 2?
   var gffbUserActionSet1 = "none";                // action set
   var gffbUserAction1 = "none";                   // user action
   var gffbScriptToExecute3 = "none";              // user script 3?
   var gffbUserActionSet2 = "none";                // action set
   var gffbUserAction2 = "none";                   // user action
   var gffbScriptToExecute4 = "none";              // user script 4?
   var gffbScriptToExecute5 = "none";              // user script 5?
   var gffbCloseFiles = "none";         
        // discard | save | saveAs JPG | saveAs PSD | saveAs TIF | none
   var gffbFnPrefix = "";                          // for save: file
   var gffbSubFolder = "new";                      // for save: sub-folder
   var gffbJpgQuality = 12;                        // JPG save quality
   var gffbJpgsRGB = true;                         // convert JPG to sRGB
   var gffbWaitRedraw = true;                 // wait for screen refresh

You may wish to tailor these with your frequently used defaults.   You can also customize a script that will run without the user dialog.   Set "gffbShowDialog=false".   Of course you would need to copy this to a new and unique script name for each set of options desired.   Otherwise, the rest of the variables are updated by the user dialog menu controls.

This should not require a high degree of programming skill but you need to adhere to some basic rules.   On each line, var defines a variable and the variable name follows.   Do not change these.   The configuration value follows the equal sign and ends with the semicolon.   Do not add or remove any quotes.   Note that true and false are keywords.   Everything after the // is merely a comment.   These lines are all near the top of the script.   You can edit them with a text editor or double click the script file from Windows Explorer or your file browser and it should open with the Adobe ExtendScript TookKit.

Hints and Tips:

The user scripts can call another action if so coded.   But the user actions employed here cannot call another script.   This is an Adobe restriction.   The basic difference is that actions are easy to record, combine, and control with Photoshop tools.   But they do not accommodate conditional tasks very well.   Scripts are very good at conditional tasks, but they require some programming skills.

With the right combination of scripts and actions, it should be possible to automate some rather comprehensive workflow tasks.   There are many sources of fee or free actions and scripts.   There are scripts to add copyright information, resize images, add text layers, and more at this web site.   Another source is: The Photoshop Scripting Community.  

For example, for a sports workflow, I use the Bridge thumbnails to discard the trash, label the exceptionally good stuff, and add some IPTC descriptions such as the player’s name.   Then I use ACR in filmstrip mode to set the crop and make any minor exposure or contrast adjustments as needed, without actually opening the images.

Then I can use GetFilesFromBridge with my final selections from the Bridge to open the images, add copyright information, remove noise, resize them, apply sharpening, save them as JPGs and create thumbnail images for the web.   All of this is from the raw images with one automation pass.   With other scripts, I can create sports trading cards.   with the player names for youth teams.   Or I can create custom HTML web pages to post the images on my website.


This script is provided as shareware with no warranty, but also no usage restrictions.   You are free to use and modify it.   If you feel obliged to pay something, make a contribution to your favorite charity.   It is available at this link in a ZIP file   This is version 1.4.  

This script needs to be extracted and installed to [PSInstall]/presets/scripts/.   Whenever new scripts are added here, Photoshop needs to be restarted to enable them.   This script will only run with Photoshop CS2 or CS3.

If you have any comments, or suggestions, I would welcome your input.   Please send me an  Email.

Rags Gardner
Rags Int., Inc.
204 Trailwood Drive
Euless, TX 76039
(817) 267-2554
Send Email
June 21, 2006
June 2, 2007

This page last updated on: Wednesday October 03 2007
You are visitor number 11,326 since 06/21/06