Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to run Photoshop batch via Javascript (vs manually selecting all attributes?)

New Here ,
Oct 26, 2021 Oct 26, 2021

Copy link to clipboard

Copied

Hello,

 

I am currently attempting to speed up my Photoshop workflow via Javascript.

 

One of the things you can do inside of Photoshop is, by pressing Control + [period], you can run an action that you've recorded in a big batch (instead of doing it individually one at a time), where you specify the source folder of images to be acted upon, and then the destination folder that you want them saved to once the batch of actions has been completed.

 

One of the actions I do in a big batch, for example, is take images of a certain size, and simply resize them for use at another step in the workflow. This is recorded as an action, and the way it works is: You come into Photoshop, select your "Set" which contains a group of actions, select your "Action" which performs the action on a given file, then select the "Source Folder" of images to perform these actions upon, and then finally, the "Destination Folder" where the finished output gets saved to after the action is performed upon it.

 

It would really simplify the workflow if I could just write a couple of Javascript programs that functionally accomplish the same thing -- because instead of having to pull up that dashboard each time, specify the set, specify the action, find the source folder and select it, then find the destination folder + select it as well -- since this process is standardized and the exact same each time in my workflow, it would just really simplify things and speed it up if I could just write a Javascript program once, and then just run that program each time I need to do this.

 

Basically I do batches OF the batches in this workflow, so being able to execute this faster would just speed it up and simplify it. So instead of pulling up that dashboard, selecting the set, selecting the action, finding the source folder, and finding the destination folder, then being able to run it from there -- and having to repeat this dozens of times -- I could instead just set up the workflow to where it's basically: Run Javascript Program 1, Run Javascript Program 2, etc, to more quickly complete this step in the process.

It seems like this would be an extremely simple chunk of Javascript code, because it only needs to accomplish four things:

 

Specify the set

Specify the action to use within that set

Specify the source folder

and 4) Specify the destination folder.

 

However I can't seem to find any online resources that clearly explain how to go about doing this via Javascript, instead of having to do it manually.

 

Is there anyone experienced with Javascript + Photoshop who knows how to do this and could help me out? I'd really appreciate it!

 

Thanks

 

 

This Adobe PDF reference definitely seems to contain the pieces needed to make this happen -- namely on p. 47 + 68 of the document, where they cover Batches -- however I have zero clue how to go about piecing these chunks of code together so that it would actually run the batch.

 

If someone could simply piece together a template of such code for me -- then I could just change the template variables (e.g. for "Set", "Action", "Source Folder" + "Destination Folder" -- it would be enormously helpful!

 

 

Here is the Adobe template I mentioned: photoshop-javascript-ref-2020.pdf

 

 

I am willing to pay for help with this if needed

TOPICS
Actions and scripting

Views

140

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Oct 27, 2021 Oct 27, 2021
We solved this on reddit, but I want to post it here too for posterity because I find myself searching for solutions and ending up on forum threads with the same question but no resolved answer. There's a shockingly small number of examples of batch methods for PS out there even when combing through Github, we ended up solving this issue with this: /** * Batch exports all documents from a given folder after executing an action * @Param {String} inputPath - Path of the source folder * @Param {...

Likes

Translate

Translate
Adobe Community Professional ,
Oct 26, 2021 Oct 26, 2021

Copy link to clipboard

Copied

Download and install Image Processor Pro... Plug-in Script.  It sounds like that is what you are after.

Up to 10 output files can be created for each image file processed an you can include a different action  to be used to help products each of  set of output files.

image.png

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 27, 2021 Oct 27, 2021

Copy link to clipboard

Copied

LATEST

We solved this on reddit, but I want to post it here too for posterity because I find myself searching for solutions and ending up on forum threads with the same question but no resolved answer. There's a shockingly small number of examples of batch methods for PS out there even when combing through Github, we ended up solving this issue with this:

 

/**
 * Batch exports all documents from a given folder after executing an action
 * @Param {String} inputPath - Path of the source folder
 * @Param {String} outputPath - Path of the destination folder
 * @Param {String} actionName - Name of the action to execute
 * @Param {String} actionSet - Name of the set containing above action
 * @Param {RegExp} [wildcard=/\.(psd|tif|jpg)$/i] - Regular Expression pattern to filter files
 */
function runBatchAction(inputPath, outputPath, actionName, actionSet, wildcard) {
  wildcard = wildcard || /\.(psd|tif|jpg)$/i;
  var files = new Folder(inputPath).getFiles(function(file) { return wildcard.test(file.name) });
  //
  // https://theiviaxx.github.io/photoshop-docs/Photoshop/BatchOptions.html
  var options = new BatchOptions();
  options.destination = BatchDestinationType.FOLDER;
  options.destinationFolder = new Folder(outputPath);
  options.overrideOpen = false;
  options.overrideSave = true;
  //
  // https://theiviaxx.github.io/photoshop-docs/Photoshop/FileNamingType.html
  options.fileNaming = [FileNamingType.DOCUMENTNAMELOWER, FileNamingType.EXTENSIONLOWER];
  app.batch(files, actionName, actionSet, options);
}

// USAGE:
runBatchAction(
  "C:/users/anton/Pictures/Next-Level Artwork/AUTOMATION ASSETS/PHOTOSHOP FILES/REMAKES 2",
  "C:/users/anton/Pictures/Next-Level Artwork/AUTOMATION ASSETS/PHOTOSHOP FILES/REMAKES 1",
  "1000px compress",
  "IMAGE RESIZING"
);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines