Skip to main content
sebd75331243
Known Participant
December 7, 2017
Answered

Running multiples scripts as sequence

  • December 7, 2017
  • 3 replies
  • 2085 views

Hi,

I'm using 4 scripts to manage all my website dev, to exports images, slice, etc..  It's an amazing way to work with scripting, god I love it !

I wonder if I can link all my script together so I don't have to wait for each one to end then start the next one manually.

Is there a way to script this so once my first script is done, it start the next one... and so on... an on... ?

Thanks guy if you have an idea !

This topic has been closed for replies.
Correct answer Kukurykus

I think you can create one script where you do as follows:

eval("//@include 'Script1.jsx'")

eval("//@include 'Script2.jsx'")

eval("//@include 'Script3.jsx'")

eval("//@include 'Script4.jsx'")

The condition is that 'Includer.jsx' script must be in the same folder what all included scripts.

I think  'Includer' script doesn't have to check was previous script already finished that next one can be started.

Simply when one won't finish its job, another will be in pending, however I'm not sure, you must check it on your own.

EDIT: I tested it creating 4 scripts (with names like those included ones in the example). Then to each of them I put:

alert(File($.fileName).name.match(/.*(?=\.)/))

As the result there popped up dialogs with consecutive names of included scripts. I mean by turns, not at once

3 replies

Inspiring
March 6, 2019

Ok, I will post this query to Indesign forum.

thanks,

hasvi

Inspiring
March 5, 2019

Hi,

I want to run 3 different scripts one by one. Need script for indesign, could you help me?

by

hasvi

Kukurykus
Legend
March 5, 2019

Not to inDesign. Didn't anything in this theard work though?

Kukurykus
KukurykusCorrect answer
Legend
December 7, 2017

I think you can create one script where you do as follows:

eval("//@include 'Script1.jsx'")

eval("//@include 'Script2.jsx'")

eval("//@include 'Script3.jsx'")

eval("//@include 'Script4.jsx'")

The condition is that 'Includer.jsx' script must be in the same folder what all included scripts.

I think  'Includer' script doesn't have to check was previous script already finished that next one can be started.

Simply when one won't finish its job, another will be in pending, however I'm not sure, you must check it on your own.

EDIT: I tested it creating 4 scripts (with names like those included ones in the example). Then to each of them I put:

alert(File($.fileName).name.match(/.*(?=\.)/))

As the result there popped up dialogs with consecutive names of included scripts. I mean by turns, not at once

sebd75331243
Known Participant
December 7, 2017

thanks

I' ve create one with script listener, which is always more coding than need, still your solution and this one work.

// start next script ----------------------------

var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );

    var desc6 = new ActionDescriptor();

    var idjsNm = charIDToTypeID( "jsNm" );

    desc6.putString( idjsNm, """File name here without extension""" );

    var idjsMs = charIDToTypeID( "jsMs" );

    desc6.putString( idjsMs, """[object Object]""" );

executeAction( idAdobeScriptAutomationScripts, desc6, DialogModes.NO );

////////////-------------------------------------------------------

Kukurykus
Legend
December 7, 2017

You may also make a loop using either Include or ScriptListener method:

for(len = (pth = File(File($.fileName).parent)

.getFiles(/t\d+.jsx$/)).length; i < len; i++) {

     eval("//@include '" + pth.name + "'")

}

for(len = (pth = File(File($.fileName).parent).getFiles(/t\d+.jsx$/)).length; i < len;) {

     function sTT(v) {return stringIDToTypeID(v)} (dsc1 = new ActionDescriptor())

     .putString(sTT('javaScriptName'), pth[i++].name.slice(0, -4))

     executeAction(sTT('AdobeScriptAutomation Scripts'), dsc1, DialogModes.NO);

}

So this way you can base on chosen files from the folder (if you keep there aslo other ones). The above will work only for names: 'Script1.jsx', 'Script2.jsx', 'Script3.jsx', 'Script4.jsx', ..., otherwise regex code must be changed to match names you used.