Run multiple GREP queries

Some replacement tasks cannot be handled by a single Find/Change operation. It's not really possible, for example, to abbreviate page ranges with a single GREP query. Instead, you need two queries for that.

Unfortunately, InDesign doesn't let you chain queries into a single action. However, the script on this page does let you do that.

When you run the script, all GREP queries from InDesign's and the user's folders are displayed in a list.

Run GREP queries

Select the queries you want to run and click Run or press Enter/Return to execute the selected queries one after another.

Note: The selected queries are executed in the order you see in the list. If you want to change the order of execution you'll have to change the names of the queries. A simple way to order queries is to prefix them with numbers.

Presets

You can create presets in which you collect any number of queries so that on a next run of the script all you need to do is to select that preset. To create a preset, select any number of queries in the list and click Preset. The script creates a small text file that contains the names of the selected queries and inserts the preset's name into the list:

Run GREP queries with a preset

A preset is named after the first-selected query and uses the file type .grep-preset.

To change a preset, simply re-create it.

To delete a preset, right-click its name in the Scripts panel and select Delete Script File:

Run GREP queries

For a more elaborate script to run and manage queries, see the GREP query manager script.

Version history

17 Mar. 2024: Bug fix and improvement of the Search dropdown.

16 Mar. 2024: Added the possibility to select the search scope.

25 Apr. 2021: Added support for query presets.

8 May 2016: Added code to get around the problem that listboxes don't display in CS6 on Windows 10.

16 Sept. 2015: Posted.


Useful script? Saved you lots of time?

Consider making a donation. To make a donation, please press the button below. This is Paypal's payment system; you don't need a Paypal account to use it: you can use several types/brands of credit and debit card.

Peter Kahrel's paypal account

Show script (right click, Save Link/Target As to download)

Back to script index

Installing and running scripts

Questions, comments? Get in touch