Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Copy link to clipboard
Copied
[ Moved the discussion here for a better response ]
Copy link to clipboard
Copied
Hi' how do i run a batch of script in javascript???
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thank buddy!
I¹l try this...
Copy link to clipboard
Copied
I just fixed a stupid typo. Make sure you have the latest.
PS: I am the other guy -- I'm acknowledging my own stupidity, not calling someone else names. My computers insist on my having two different personalities here depending on which one I use.
Copy link to clipboard
Copied
ok got it!