6 Replies Latest reply on Dec 7, 2017 11:13 AM by sebd75331243

    Running multiples scripts as sequence

    sebd75331243 Level 1



      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 !

        • 1. Re: Running multiples scripts as sequence
          Kukurykus Level 3

          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:




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

          • 2. Re: Running multiples scripts as sequence
            sebd75331243 Level 1



            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 );


            • 3. Re: Running multiples scripts as sequence
              Kukurykus Level 3

              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[i].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.

              1 person found this helpful
              • 4. Re: Running multiples scripts as sequence
                r-bin Level 4

                i is undefined )



                I would use $.evalFile ( )



                • 5. Re: Running multiples scripts as sequence
                  Kukurykus Level 3

                  Yes it is, but it works I'm not sure but it might make only problem when some i will be used in one of those 4 scripts.


                  Longer time I scripted in CS2 where $.evalFile() wasn't present. I'm just used to still using simple eval


                  Whatever i is (un)defined I got strange result. Scripts were always opened in this order:


                  Script1, Script2, Script4, Script3. I recreated them but still that happens, why?

                  • 6. Re: Running multiples scripts as sequence
                    sebd75331243 Level 1

                    I used it at the end of each script, so rather than stop it start the next one.