Skip to main content
Participant
September 27, 2013
Question

Scripting

  • September 27, 2013
  • 2 replies
  • 1243 views

I everyone! i'm knew to this forum and i would like ti know if anyone would know how to run a batch of jacascript in inDesign.

Thank in advance

This topic has been closed for replies.

2 replies

PrintFusion45
Participating Frequently
September 27, 2013

[ Moved the discussion here for a better response ]

Participant
September 27, 2013

Hi' how do i run a batch of script in javascript???

Inspiring
September 27, 2013

They could call each other in a chain (which is an incovenient approach because you'd have to edit each one) or you could write a new script to call each of them in turn.

Here's some snippets of code that should help. It runs all the scripts in a folder.

if (scriptsFolder.exists) {

          var myScripts = scriptsFolder.getFiles(checkForScripts);

          myScripts.sort(); // Force scripts to run in JS alphabetical order

          for (var scriptIndex = 0; myScripts.length > scriptIndex; scriptIndex++) {

                    app.doScript(myScripts[scriptIndex]);

          } // end for

}

...

function checkForScripts(aFile) {

          if (aFile instanceof Folder) return false;

          var extn = aFile.name.slice(aFile.name.lastIndexOf("."));

          if (extn === aFile.name) return false; // file name lacks extension;

          switch (extn) {

               case ".jsx" : case ".jsxbin" : return true;

               default : return false;

          }

} // end checkForScripts;

To use that code you'll need to put it into the context of a larger script that at the very least provides a value for scriptsFolder. The ... I use to separate the function from the other code will need to go in order for you to run the code.

Dave

Mike Witherell
Community Expert
Community Expert
September 27, 2013