Run a Sequence of Scripts in Adobe InDesign

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 waiting for one script to complete before you can run the next one. It doesn’t make sense.

It would be great to set a queue of scripts to be executed. But alas there isn’t such feature within InDesign. Developers know how to prepare this kind of sequence very easily. We have made a new panel for the non-scripters : BatchRunner.

Scripting a sequence

Javacsript offers a method for executing external scripts : doScript. This method belongs to the Application object (app). It can execute code contained within the same script or an external file. We will focus on the file feature.

any doScript (script: {File | String | JavaScript Function} [, language: ScriptLanguage=ScriptLanguage.UNKNOWN][, withArguments: Array of any][, undoMode: UndoModes=UndoModes.SCRIPT_REQUEST][,undoName: string=Script]) Executes the script in the specified language as a single transaction.


I won’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, the following script will run all the files defined as variables.

function batch()
{
   var f1 = File ( "script_1.jsx" );
   var f2 = File ( "script_2.jsx" );
   var f3 = File ( "script_3.jsx" );

   app.doScript ( f1 );
   app.doScript ( f2 );
   app.doScript ( f3 );
}

batch();

It’s very easy to arrange a script sequence. But for some people, it can be scary or painful to deal with code. Hence our interest for a tool that would ease the conception and execution of scripts without any development. Here is BatchRunner.

BatchRunner

BatchRunner is an extension located in the “Window/Extensions” menu. Once run, the panel displays a very simple UI.

UI BatchRunner

Key elements of the UI are :

1. The scripts listing (hosts every single scripts located in the Scripts palette)

2. The Sequence list (any script placed here will be run in the sequence)

3. The go button (run the sequence)

Create a séquence

For this demo, we have prepared three scripts ( 1.jsx, 2.jsx, 3.jsx).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 regular expression: ^\d

filter

Now, it only remains our three scripts. To get started, we just need to drag scripts from within the scripts list (1) and drop them into the sequence list (2).

Drag Scripts

Run a séquence

Your sequence is ready. Click now on the “Go” button.

What do we have ?

alertes 1 2 3

Our three scripts are executed in the order we set. Besides, if we modify the order of the sequence, the scripts are executed accordingly to the new disposition.

Without a signle line of code, we can easily create sequence and reorder them.

Execution context

Keep in mind that BatchRunner only run scripts one by one and doesn’t check any execution context. Once that said, choose to run your sequence once or to repeat it through the open documents (Docs) or through a selection of files (Files).

Presets

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. You can choose to create custom presets to organise your sequences.

We hope this panel will boost your productivity even more. Feel free to comment this product and share your appreciations.

Cheers,

Download BatchRunner

2 thoughts on “Run a Sequence of Scripts in Adobe InDesign

  1. For some reason this script isn’t working on my home mac. The one at work, fine… but not on my mac at home, which is 10.6.8 running indesign cs6 (8.01). Only thing I could think of is that the home mac’s script panel folder could be different – i did away with the “samples” folder and just moved the javascripts into the scripts panel root directory. Is there a specific directory/directories that the script is looking for?

  2. Hi Colin,

    Nice to see you around. The panel uses a property of the scriptPreferences :
    app.scriptPreferences.scriptsList;

    The script folder can be found by : app.scriptPreferences.scriptsFolder
    Which in my CS6 case gives : ~/Library/Preferences/Adobe InDesign/Version 8.0/fr_FR/Scripts/Scripts Panel

    I don’t think you can define another folder of your own. So the panel just finds something. Feel free to send me more details by mail.

    Loic

Leave a Reply

Your email address will not be published. Required fields are marked *