Using Scripts For Automation

Many of our blogs focus on using a script to automate a process. This assumes that the reader has some experience using scripts. With the idea that this may not be the case, this blog takes a step backward to introduce the basics: scripts, the Scripts panel, and Keyboard Shortcuts.

Scripts

For the purpose of this blog, we will define scripts as files containing programming code that targets a specific application, often performing a set of steps to automate a process. For Adobe InDesign, these files can be saved in a folder named Scripts Panel residing in the application’s Scripts folder.

Once installed in the folder, the scripts can be accessed from InDesign’ Scripts panel (Window > Utilities > Scripts). For those scripts that are used frequently, you may want to set up a Keyboard Shortcut.

Keyboard Shortcuts

You can set up any number of custom Keyboard Shortcuts from the application’s Keyboard Shortcuts panel (Edit > Keyboard Shortcuts…)

First, you will want to create a shortcut set just for your scripts. For this, click on the New Set… button to the right of the Keyboard Shortcuts panel. Give your set a name and base it on Default. Click OK. 

With your set established, change the Product Area to Scripts.

Next find the script for which you want to create a Keyboard Shortcut in the Commands list. The name of all scripts placed in the Scripts Panel folder will be prefixed with the word “Application:”. This is because the script was placed in the Application’s Script Panel folder.

Once you have found the script, click on it and enter the shortcut you want to use in the New Shortcut: text field. I use an Option+Shift key combination almost exclusively since Option+Shift is fairly open for use. (Other combinations may already be in use by the application.) If the key combination you enter has not been used, you can then click the Assign button to assign it.

You can go on to assign shortcuts to other scripts as needed. When through, click the OK button to close the dialog.

You most likely noticed that there were a number of scripts in the script listing that begin with the words Application:Samples:. These scripts are distributed with the application courtesy of Adobe. There are some very useful scripts in this collection, so check them out when you have time. To look at a script, select it and choose Edit Script from the Script Panel’s menu. A description of the script’s functionality should be at the top of the file.

The User’s Script Panel

There is another location on your computer designated for InDesign scripts. This is the User Scripts Panel folder which is a little harder to find than that for the Application’s Scripts Panel. The easiest way to discover where this folder is located is to open the Scripts Panel in InDesign. Go to the bottom of the script list to find the little User folder icon. With its entry selected, select Reveal in Finder from the Script Panel menu. Select the folder in the Finder window and choose Get Info from Finder’s File menu (Command+I). Under the “Where:” heading you will see the path to the folder. As you can see, it is not the easiest folder to find, but may end up being your script folder of choice.

Create Document from Template

To demonstrate using a script, we have created a simple script to create an InDesign document from a template. A template file and a placeholder image file is included with the script in the download. (See Sample Script heading in either the AppleScript or ExtendScript page). Templates can be great time savers and having a script to facilitate using the template is a bonus.

Our sample script is a very simple script that has the user select the template from a list. From there InDesign creates a new document from the template ready for editing and content placement. The script assumes that templates will be saved in a folder named Templates in the application’s Templates folder.

To test the script, install it in InDesign’s Script Panel. Assign it a Keyboard Shortcut if so desired. Place the template file and the Placeholder image file in a folder named Templates inside the application’s folder.

With InDesign as the frontmost application, run the script by double-clicking on the script in the Script Panel or using your Keyboard Shortcut. Select iPadBasic.indt from the list presented.

A new document is created from the template in seconds, much less time than it would take you to find the template or create a new document from scratch.

Modifying the Document

Notice that the new document has placeholders for an image and text. If you sample any of the text, you will discover that the type font Georgia has been used throughout. Because all paragraph styles are based on [Basic Paragraph], changing the type font for the text requires one simple step: changing the font for [Basic Paragraph]. For this, make sure nothing is selected in the document and double click on [Basic Paragraph] in the Paragraph Styles panel (Window > Styles > Paragraph Styles). Click on Basic Character Formats in the Paragraph Style Options dialog and change the designated font in the Font Family drop down.

Click OK and the font for all of the paragraph styles should be changed.

The document has three master pages. If your new document does not need a Section page, replace its designated master page with Master A. Add pages as needed.

Using a template is just one way you can shortcut the document creation process. We will look at another method in a forthcoming blog.