How can I have my .jsx script when finished execute another .jsx script?
Maybe this will help understand what I am trying to do:
// WebCard.jsx file
function mySnippet(){
//<fragment>
var myPageName, myFilePath, myFile;
var myDocument = app.documents.item(0);
var myBaseName = myDocument.name;
for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
myPageName = myDocument.pages.item(myCounter).name;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
app.jpegExportPreferences.resolution = 96;
app.jpegExportPreferences.pageString = myPageName;
switch(myPageName) {
case "1" : myPageName = "EN FRONT WebCard";
docType = "Web/Web Cards" break;
case "2" : myPageName = "EN BACK WebCard";
docType = "Web/Web Cards" break;
case "3" : myPageName = "ES FRONT WebCard";
docType = "Web/Web Cards" break;
case "4" : myPageName = "ES BACK WebCard";
docType = "Web/Web Cards" break;
}
fileName = group + " " + myPageName + " " + date + ".jpg";
myFilePath = dirPath + docType + "/" + fileName;
myDocument.exportFile(ExportFormat.jpg, File(myFilePath), false);
}
//</fragment>
}
//</snippet>
// execute PrintCard.jsx file
//<teardown>
function myTeardown(){
}
//</teardown>
To run the script, open a document in InDesign, then open the Scripts panel (see above) and double-click the script name. Some scripts require you make a selection first before you run them, because they act on the selection. See if the script writer provided any sort of documentation if you can't figure it out.
Open the Scripts panel Choose Window > Utilities > Scripts.
Since JSX files are used in Adobe's programs, you can open them with Photoshop, InDesign, and After Effects from the File > Scripts > Browse menu item. This is also where these programs import JS and JSXBIN files. Like most source code, JSX files are really just text files, so any text editor can open them for editing.
You can easily include another script which will be executed at the point where you include it:
// ... Do something (will be executed before teardown script)
#include "../path/to/teardown/script.jsx"
// the path can be absolute or relative.
This should work in InDesign from CS3 upwards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With