In this blog post, I want to talk a bit about the secretive Script Label in InDesign.
You might have noticed the Script Label palette, and wondered what it was used for – it’s under Windows – Automation – Script Label.
First I’ll explain what it is all about, and then I’ll dive into some practical scenarios to show you how you can use the Script Label to save lots of time. Most of the info in this blog post is applicable to Mac and Windows versions of InDesign CS, CS2, CS3 or CS4.
1. Big Word of the Day: Meta-Information
In most companies or institutions, ‘Adobe InDesign’ does not live on an island. It’s a cog in a bigger system.
There is a natural ‘flow’ of information throughout the company – orders or requests come in, and somewhere along the line, designers build or modify InDesign documents based on information they receive one way or another – a project brief, a meeting, an e-mail, a telephone call…
Then they pass the result of their work on to the next person or system down the line – as an InDesign file, an InCopy file, a PDF file, a web page, a stack of physical paper,…
In some companies, this flow of information is informal and unstructured.
In other companies (typically larger ones), the flow of information has more or less structure. There are rules and procedures and regulations. You’ll hear about things like ‘order forms’ or ‘job tickets’ or ‘job jackets’ being passed around.
Sometimes there are tangible envelopes or manilla folders with stuff in them, sometimes there is just electronic data being passed around via a central computer system…
In all this hustle and bustle, having a way to keep some tidbits of extra information about an InDesign document inside the document can come in very handy.
This extra info is not meant to be part of the printed end-result. Instead it provides you with critical info about the document: who is the customer? By when is it due? Who should you ring if you have questions? What inks can you use? What is the target resolution? How many pages can you have? And so on…
All such information is sometimes referred to as meta-information – it’s information about how to treat the information in the document.
Having the answers to questions like the ones above readily available ‘inside’ the InDesign document can make a world of difference. No need to ring around in order to figure something out if the info is right there for you to read, inside the document.
There are many ways to do this.
You might have a simple text frame out on the pasteboard with information typed into it. (On a related note – you might want to check out our free HistoryLog plug-in – it uses this idea to provide you with an automatic document history. https://www.rorohiko.com/wordpress/indesign-downloads/history-log/).
You might be using part of the document name to refer to the customer code or hold a deadline date (e.g. so you’d know that a document called RORO12_20091112.indd is related to customer code RORO12 and is due by 12-Nov-2009).
Meta-information is where the Script Label comes in handy: the Script Label is a convenient way to attach a little bit of text, any text, to a page item.
InDesign does not care what text you attach. Whatever you put into the script label won’t normally affect the output of your document – but it’ll keep the text with the page item.
2. Practical Use of the Script Label
Some people use the Script Label to tag page items for automated processing by a script – hence its name ‘Script Label’: it is very often used by script developers.
However, it is not limited to just that. Your imagination is the limit.
I’ve made up a sample scenario here – read it, and that might give you some new ideas. I’ve called this scenario ‘the todo-list-scenario’.
There’s some scripting involved, but you don’t need any scripting knowledge to make use of it – if you can follow instructions, you should be able to make this work.
The problem: imagine I have a spread with heaps of text frames, and all of these page items need to be inspected. Some of them need to be modified depending on what I find.
Suppose all these text frames contain customer comments for the Playamathing toy, and they might or might not contain a reference to a color.
There’s a frame that contains the text “I really love the red Playamathing”. Another says “The yellow Playamathing with the extra knobs is my favourite”, and so on… Imagine there are hundreds of those frames, scattered all over the layout in a fairly haphazard layout.
My task is to read all these bits of text, and change the background of the frames to match the color mentioned, if there is one. If no color is mentioned, I am to leave the background white.
How do I keep track of which ones I’ve inspected and which ones I still need to do? Script Label to the rescue!
2.1 Marking page items with a script label
First of all, I select all text frames. Then I bring up the Script Label palette and type ‘TODO’ in it. Then I click somewhere in the pasteboard area. Through that simple manipulation, I’ve now ‘marked’ all selected text frames with a script label ‘TODO’.
I now keep the Script Label palette open, and each time I finish one of the text frames, I simply remove the ‘TODO’ from the script label for that text frame.
2.2 Using Scripts
This approach is still rather cumbersome, and we’ll improve it through a few simple scripts and keyboard shortcuts. Here’s how!
Open a text editor. You could use Notepad on Windows, or TextWrangler (http://www.barebones.com) on Mac.
Don’t use the Apple-provided TextEditor – it will try to save your script in RTF format instead of plain text, and then it won’t work.
Tip: if you’re really in a bind, Stickies (the sticky-note app that comes with Mac OS X) works better than TextEditor when it comes to creating plain text files.
Type the following text into a new text file:
app.selection[0].label = "TODO";
This is a one-line script. There are a few small ‘gotchas’, and I’ll discuss those later, but it’ll do.
Save the one-line text document into a file called mark_todo.jsx
Make sure the file extension is .jsx, not something else. It’s easy to accidentally create a file called mark_todo.jsx.txt (with an extra .txt file name extension). To compound that problem, the Windows Explorer or Mac Finder are often configured to not show the final .txt, and hence such a file might look OK, yet refuse to work. Be aware that what looks like a .jsx file might not be one.
Now, store this mark_todo.jsx file in the InDesign Scripts – Scripts Panels folder. Go to your InDesign application folder, then into Scripts, then into Scripts Panels. Put the mark_todo.jsx file there.
(A method to quickly get to the Scripts Panel folder is to right-click or control-click the Application folder on the Scripts Palette in InDesign and then select Reveal in Finder or Reveal in Explorer).
Now duplicate mark_todo.jsx file, and rename the duplicated file to unmark_todo.jsx. Then open unmark_todo.jsx in your text editor and eliminate the four letters of TODO, so it reads:
app.selection[0].label = "";
Go back to InDesign. On the Scripts Palette in InDesign, when you double-click either mark_todo.jsx or unmark_todo.jsx, they will look at the current selection, then take the very first item in that selection, and adjust the script label of that item to either be TODO or nothing.
These two scripts have some limitations, as you’ll find out. Try this: make sure no page item is selected and then double-click either one of them on the scripts palette.
You get a nice big fat error dialog: the script is trying to access part of ‘the selection’ and nothing is selected, so InDesign is a little bit unhappy about that.
Not to worry! You can safely ignore this – nothing bad has happened. We’ll just live with that behavior for now – simply keep in mind that you must have a single item selected before running either script.
2.3 Using Keyboard Shortcuts
The next step is to assign some keyboard shortcuts to these two scripts. Go to Edit – Keyboard Shortcuts, and create a new set if necessary – I created a set called Todo Script Set. Go into the Product Area Scripts, and then assign shortcuts to the two scripts – on my Mac, I’ve assigned them Ctrl+T and Ctrl+U. On Windows you might want to pick some other shortcuts – pick something that works for you.
The scripts palette should now show these shortcuts next to the scripts. Bring the Script Label palette into view, select a page item and repeatedly hit Ctrl+T followed by Ctrl+U while observing the Script Label palette. The word TODO should appear and disappear from the Script Label palette each time you hit the shortcut.
That’s another step in the right direction – marking and unmarking individual page items just became a whole lot easier.
2.4 Finding marked items
Now the next question is: how to quickly find page items that still have a ‘TODO’ script label? Sadly enough the standard ‘Find’ function in InDesign does not seem to be of much help.
Scripting to the rescue! Below a script that finds the next item with a ‘TODO’ script label.
do { if (app.documents.length == 0) { break; } var document = app.activeDocument; if (! (document instanceof Document)) { break; } var currentItem = null; if (app.selection.length > 0) { currentItem = app.selection[0]; } var undoneItems = []; for (var idx = 0; idx < document.allPageItems.length; idx++) { var pageItem = document.allPageItems[idx]; if (pageItem.label == "TODO") { undoneItems.push(pageItem); } } if (undoneItems.length <= 0) { break; } var nextItemIdx = 0; if (currentItem != null) { var currentItemIdx = -1; var searchItemIdx = 0; while (currentItemIdx == -1 && searchItemIdx < undoneItems.length) { if (undoneItems[searchItemIdx] == currentItem) { currentItemIdx = searchItemIdx; } searchItemIdx++; } if (currentItemIdx >= 0) { nextItemIdx = currentItemIdx + 1; if (nextItemIdx >= undoneItems.length) { nextItemIdx = 0; } } } app.select(undoneItems[nextItemIdx]); } while (false);
I won’t elaborate on how this script works – if you’ve done some ExtendScript-ing before it should be fairly easy to follow. If you’re new to ExtendScript – simply make sure you copy the script verbatim.
Save this script to your Scripts Panel folder as next_todo.jsx.
Each time you double-click this script, the currently selected item will ‘jump’ to the next item that still has a TODO label. You can assign another shortcut key to this script – I used Ctrl+N on my Mac. Each time I hit Ctrl+N, my selection jumps to the next page item with a TODO label.
2.5 Seeing Marked Items
We’re not done yet! If you install our FrameReporter plug-in (https://www.rorohiko.com/framereporter) you can configure it to visually show the script labels. With FrameReporter active, and configured like this:
I can do Select All on my spread, and I get to see this:
I can immediately see that two of the three items still haven’t been examined. Unlike most of our plug-ins, FrameReporter is not a freebie, but it’s still a steal at just US$29.
2.6 InDesign CS4 Live Preflight
But wait, there is more! Soon, we’ll have the YeShore plug-in available which extends the InDesign CS4 Live Preflight (https://www.rorohiko.com/wordpress/yeshore). It has a number of powerful new preflight rules, one of which involves script labels.
If you have YeShore installed (e.g. because you’re on our beta program – check the web page to find out more), you can configure a rule to find all unfinished page items:
I’ve made a preflight profile called ‘Check all done’ and added a rule that says that the script label should not be TODO. With this profile active, it becomes very easy to see how many items I still have to handle, and to ‘hop’ to any items that are still marked as TODO. I simply click on one of the lines in the Preflight panel and InDesign immediately selects the corresponding item.
3. Conclusion
I hope that these samples are useful! And if you’re interested, check out FrameReporter, or stay tuned to hear more about YeShore!
Cheers,
Kris