is now part of CreativePro.com!

A Script for Counting List Items

3

Here’s a nifty little script that gives InDesign the ability to find the number of paragraphs set in a certain paragraph style and make that number appear in your document. It’s great for displaying the number of list items, steps in a series of instructions, etc.

The script is called Count Number of Steps, and it’s the work of Kasyan Servetsky, who generously created it in response to a question on the Adobe InDesign User Forum.

Here’s a potential use case. Say you have a bunch of lists with headings, like so:

How to Prepare for PePCon list

The list items are styled with a paragraph style called Steps and the title is styled with a paragraph style called Header.

In the title you’d also like to include the number of items in the list, like so:

How to Prepare for PePCon steps

The script saves you the effort of checking the number of steps and typing it in the title. It works by looking for a series of numbered paragraphs with a paragraph style called “Steps” applied to them.

It then checks the number of the last paragraph in the series (in this case 10), and inserts that number in a text string at the end of the preceding paragraph styled with Header. If the number is already there, the script will update it to match the current last number in the Steps paragraphs.

You don’t need to have anything selected for the script to work. It will find all instances of the styles and apply the correct numbering.

Ah, but what if you don’t use styles called Steps and Header? No problem! Just open the script in a text editor and Find/Change all instances of the style names to whatever you use in your InDesign document.

Find/Change style names in script

Note that the name of the style applied to the steps or list items is what will appear in parentheses in the header. Also note that in the example below, the formatting of the text inserted by the script comes from a nested style in the Header paragraph style. The script doesn’t apply any formatting.

How to Prepare for PePCon list with count

Editor in Chief of CreativePro. Instructor at LinkedIn Learning with courses on InDesign, Illustrator, Photoshop, GIMP, Inkscape, and Affinity Publisher. Co-author of The Photoshop Visual Quickstart Guide with Nigel French.
  • I can already see a use for it with cookbooks, instruction assembly manuals and catalogues.

    One improvement that I wish I knew how to write is the ability to include sub-points (i.e. if a line had a few bullet points after it, but then carried on with the “Steps” style). Just tried a sample and it didn’t go as planned if there were bullet points within the lines to be counted.

    And so far as Chicago references go… no Blues Brothers clichés? There is also recently released console game called “Watchdogs” that is set in Chicago… so while I can’t make it to PEPCON, I can pretend I’m there!

    • Mike Rankin says:

      Wow, total missed opportunity on my part! How’s this: #11: Nighttime supplies: full tank of gas, half a pack of cigarettes, sunglasses.

      Also, another potential upgrade: Kasyan mentioned the idea of adding code that would display a dialog box where you can enter the style names instead of having to Find/Change the script.

  • LuisRM says:

    #10 was great and I think the #6 font joke has potential.

    Two fonts walk into a bar and the bartender says “Hey, we don’t serve fonts here!” But the fonts sat down anyway because they were bold.

    Looking forward to your PepCon “5 Essential Effects in InDesign” presentation Mike.

  • >