InDesign scripting : lesson 04

the first scripting lesson – lesson 01 – suggested you save your InDesign applescripts in script file format (.scpt). but there’s a very good reason why you should ignore such nonsensical advice and save them in text file format (.applescript) instead :

Script Editor screen grab. shows saving in text file format

both file formats work equally well from the InDesign scripts panel, but the fact is you cannot search the contents of .scpts through spotlight, but you CAN search through the contents of .applescript files because they are essentially text files. why is searchability important? because when you get more involved in scripting and you have dozens and dozens of scripts and script snippets lying around, it helps to be able to search for that little bit of code that you used somewhere in some kind of script a couple of months ago but can’t quite remember which one.

ok? cool. on with the lesson. here’s a script for just about everyone who uses InDesign. everyone, that is, except those who never need to print an InDesign file. one very cool thing about this script is that it will work for every version of InDesign from CS2 through to CS5.5 (it may even work with earlier versions). usually scripts have to be adapted between versions due to changing syntax rules and whatnot. the only thing you may need to change with this one is your version number in the first line :

Screen grab of Print All Files script

you can get the complete script here — PrintAllFiles

now, having diligently studied the first three lessons, you’ll instantly see that this script has two ‘tell’ blocks. the first addresses the application and the second addresses ‘every document’. between the two ‘tell’ statements we’re capturing some information. (by the way, if you don’t understand why those bits of text are green you should review lesson 03) first, we’re getting a list of all of InDesign’s printer presets. then, we’re using a handy applescript command – ‘choose from list’ – to create a dialog box from which the user can make a selection :

screen grab showing printer preset list

we’ve included two optional parameters with the ‘choose from list command’ – ‘with prompt’ and ‘with title’. you can change those two bits of black text between the quotation marks to whatever takes your fancy. or you can get rid of those optional parameters altogether – see what happens.

the guts of the script is, of course, in the next ‘tell’ block. now, we could have just written :

tell every document
end tell

but that would give us the same result as hitting command-p for every document – no benefit there at all, because we have to click OK for every print dialog window. curiously, the same would happen even if we added the “using (name of printer preset)” bit.

the real magic is in the last part – “without print dialog”. as well as suppressing the usual print dialog, this part of the command also kills the usual ‘missing links’ dialog as well. for the workflow this script was developed for, this is perfect because that bloody dialog is just a pain. ymmv.

you’ll find this script will save time even if you have a single document to print — just two double-clicks and you’re done. but it really kicks arse when you need to print multiple documents using the same preset.

macgrunt icon

thoughtful and respectful comments welcome

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s