{"id":1328,"date":"2013-04-11T11:20:36","date_gmt":"2013-04-11T09:20:36","guid":{"rendered":"http:\/\/www.ozalto.com\/?p=1328"},"modified":"2013-11-07T15:36:19","modified_gmt":"2013-11-07T13:36:19","slug":"run-a-sequence-of-scripts-in-adobe-indesign","status":"publish","type":"post","link":"https:\/\/www.ozalto.com\/en\/run-a-sequence-of-scripts-in-adobe-indesign\/","title":{"rendered":"Run a Sequence of Scripts in Adobe InDesign"},"content":{"rendered":"<p><strong>You may use scripts already<\/strong> in Adobe InDesign. Scripts are great for automating and securing your workflow. But in case you want <strong>to run several scripts, you have to execute them one by one<\/strong>.<\/p>\n<p>Most of these routines only take (milli)seconds. But a few of them can be more time consuming. Eventually, you are just waiting for one script to complete before you can run the next one. <strong>It doesn&#8217;t make sense.<\/strong><\/p>\n<p><!--more--><\/p>\n<p>It would be great to set a queue of scripts to be executed. But alas there isn&#8217;t such feature within InDesign. Developers know how to prepare this kind of sequence very easily. We have made<strong> a new panel for the non-scripters : BatchRunner.<\/strong><\/p>\n<h4>Scripting a sequence<\/h4>\n<p>Javacsript offers a method for executing external scripts : <strong>doScript<\/strong>. This method belongs to the Application object (app). <strong>It can execute code contained within the same script or an external file.<\/strong> We will focus on the file feature.<\/p>\n<div style=\"padding: 10px; background-color: #f6f6f6;\">any <strong>doScript<\/strong> (<strong>script: {File | String | JavaScript Function}<\/strong> [, language: ScriptLanguage=ScriptLanguage.UNKNOWN][, withArguments: Array of any][, undoMode: UndoModes=UndoModes.SCRIPT_REQUEST][,undoName: string=Script]) <em>Executes the script in the specified language as a single transaction.<\/em><\/div>\n<p><br class=' sb-br' \/>I won&#8217;t dig further on the doScript method. If you are interested, have a look at the Adobe InDesign Scripting guide. With this short introduction, you can foresee how we are actually going to run a sequence of scripts. For example, <strong>the following script will run all the files defined as variables.<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction batch()\r\n{\r\n   var f1 = File ( &quot;script_1.jsx&quot; );\r\n   var f2 = File ( &quot;script_2.jsx&quot; );\r\n   var f3 = File ( &quot;script_3.jsx&quot; );\r\n\r\n   app.doScript ( f1 );\r\n   app.doScript ( f2 );\r\n   app.doScript ( f3 );\r\n}\r\n\r\nbatch();\r\n<\/pre>\n<p>It&#8217;s very <strong>easy to arrange a script sequence.<\/strong> But for some people, it can be scary or painful to deal with code. <strong>Hence our interest for a tool that would ease the conception and execution of scripts without any development. Here is BatchRunner.<\/strong><\/p>\n<h4>BatchRunner<\/h4>\n<p><strong>BatchRunner is an extension<\/strong>\u00a0located in the &#8220;Window\/Extensions&#8221; menu. Once run, the panel displays a very simple UI.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"size-full wp-image-1316\" title=\"BatchRunner_UI\" alt=\"UI BatchRunner\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/BatchRunner_UI.png\" width=\"358\" height=\"591\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/BatchRunner_UI.png 358w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/BatchRunner_UI-181x300.png 181w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/BatchRunner_UI-224x370.png 224w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/BatchRunner_UI-36x60.png 36w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/BatchRunner_UI-190x315.png 190w\" sizes=\"(max-width: 358px) 100vw, 358px\" \/><\/p>\n<p><strong>Key elements of the UI are :<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong>1. The scripts listing<\/strong> (hosts every single scripts located in the Scripts palette)<\/p>\n<p style=\"padding-left: 30px;\"><strong>2. The Sequence list<\/strong> (any script placed here will be run in the sequence)<\/p>\n<p style=\"padding-left: 30px;\"><strong>3. The go button<\/strong> (run the sequence)<\/p>\n<h4>Create a s\u00e9quence<\/h4>\n<p>For this demo, <strong>we have prepared three scripts ( 1.jsx, 2.jsx, 3.jsx)<\/strong>.These scripts will only display their file name in a dialog. It will just let us check that everything is running fine. As our list is really large, we are using the filter field. We are typing in a <strong>regular expression: ^\\d<\/strong><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1317\" title=\"filter\" alt=\"filter\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/filter.png\" width=\"337\" height=\"230\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/filter.png 337w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/filter-300x204.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/filter-87x60.png 87w\" sizes=\"(max-width: 337px) 100vw, 337px\" \/><\/p>\n<p>Now, it only remains our three scripts.\u00a0To get started, we just need to <strong>drag scripts from within the scripts list (1) and drop them into the sequence list (2).<\/strong><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1318\" title=\"dragScrips\" alt=\"Drag Scripts\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/dragScrips.png\" width=\"361\" height=\"327\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/dragScrips.png 361w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/dragScrips-300x271.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/dragScrips-66x60.png 66w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/dragScrips-347x315.png 347w\" sizes=\"(max-width: 361px) 100vw, 361px\" \/><\/p>\n<h4>Run a s\u00e9quence<\/h4>\n<p>Your sequence is ready.\u00a0<strong>Click now on the &#8220;Go&#8221; button.<\/strong><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1319\" title=\"Run Sequence\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/RunSequence.png\" width=\"338\" height=\"284\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/RunSequence.png 338w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/RunSequence-300x252.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/RunSequence-71x60.png 71w\" sizes=\"(max-width: 338px) 100vw, 338px\" \/><\/p>\n<h4><\/h4>\n<p><strong>What do we have ?<\/strong><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1320\" title=\"alerts1.jsx\" alt=\"alertes 1 2 3\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts1.jsx_.png\" width=\"420\" height=\"486\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts1.jsx_.png 420w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts1.jsx_-259x300.png 259w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts1.jsx_-319x370.png 319w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts1.jsx_-51x60.png 51w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts1.jsx_-272x315.png 272w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/p>\n<p><strong>Our three scripts are executed in the order we set. <\/strong>Besides, if we modify the order of the sequence, the scripts are executed accordingly to the new disposition.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1321\" title=\"changement Ordre\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/changementOrdre.png\" width=\"331\" height=\"96\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/changementOrdre.png 331w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/changementOrdre-300x87.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/changementOrdre-120x34.png 120w\" sizes=\"(max-width: 331px) 100vw, 331px\" \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1322\" title=\"alerts2.jsx\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts2.jsx_.png\" width=\"420\" height=\"486\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts2.jsx_.png 420w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts2.jsx_-259x300.png 259w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts2.jsx_-319x370.png 319w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts2.jsx_-51x60.png 51w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/alerts2.jsx_-272x315.png 272w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/p>\n<p>Without a signle line of code, <strong>we can easily create sequence and reorder them.<\/strong><\/p>\n<h4>Execution context<\/h4>\n<p>Keep in mind that BatchRunner only run scripts one by one and <strong>doesn&#8217;t check any execution context. <\/strong>Once that said,<strong> choose to run your sequence once or to repeat it through the open documents (Docs) or through a selection of files (Files).<\/strong><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1323\" title=\"buttons\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/buttons.png\" width=\"336\" height=\"50\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/buttons.png 336w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/buttons-300x44.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/buttons-120x17.png 120w\" sizes=\"(max-width: 336px) 100vw, 336px\" \/><\/p>\n<h4>Presets<\/h4>\n<p>Everything is stored. If you add a script within a sequence, you will find it your sequence back when you open the panel next time. <strong>You can choose to create custom presets to organise your sequences.<\/strong><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1326\" title=\"presetButton\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetButton.png\" width=\"338\" height=\"31\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetButton.png 338w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetButton-300x27.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetButton-120x11.png 120w\" sizes=\"(max-width: 338px) 100vw, 338px\" \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1325\" title=\"presetInput\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetInput.png\" width=\"152\" height=\"128\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetInput.png 152w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetInput-71x60.png 71w\" sizes=\"(max-width: 152px) 100vw, 152px\" \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1324\" title=\"presetCombobox\" alt=\"\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetCombobox.png\" width=\"285\" height=\"75\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetCombobox.png 285w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2013\/04\/presetCombobox-120x31.png 120w\" sizes=\"(max-width: 285px) 100vw, 285px\" \/><\/p>\n<p><strong>We hope this panel will boost your productivity even more.<\/strong>\u00a0Feel free to comment this product and share your appreciations.<\/p>\n<p>Cheers,<\/p>\n<p><a title=\"T\u00e9l\u00e9charger BatchRunner\" href=\"http:\/\/support.ozalto.com\/downloads\/BatchRunner.zxp\" target=\"_blank\">Download BatchRunner<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may use scripts already in Adobe InDesign. Scripts are great for automating and securing your workflow. But in case you want to run several scripts, you have to execute them one by one. Most of these routines only take (milli)seconds. But a few of them can be more time consuming. Eventually, you are just [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1327,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1328\/"}],"collection":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/"}],"about":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/types\/post\/"}],"author":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/users\/2\/"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/comments\/?post=1328"}],"version-history":[{"count":0,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1328\/revisions\/"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/1327\/"}],"wp:attachment":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/?parent=1328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/categories\/?post=1328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/tags\/?post=1328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}