A GREP queries manager

If you use GREP queries a lot, it's easy to lose track of what's in which query. The script displays an overview of all GREP queries, showing each query's name, find expression, and change expression. Using the script, you can load a query into the GREP editor (a separate script; see GREP editor) or copy it into the Find/Change dialog. You can also copy the contents of GREP queries to one or more paragraph styles, duplicate and rename queries, and execute one or more queries.

The script displays the contents of all GREP queries in the current user's folder as shown in the screenshot. It looks in the user's folder only. Information is displayed in three columns. Query: the name of the query on disk, i.e. the name under which you originally saved the query; Find what: the contents of the Find what field in the Find/Change folder; Change to: the contents of the Change to field in the Find/Change folder. If a field has no contents, the script replaces shows that by printing ---- for clarity. The functions of the buttons are explained below.

GREP queries overview

Edit query in GREP editor

Press Edit query in GREP editor to load the Find-what part of the query in the GREP editor, which is a separate script. (If the script can't be found, the button is disabled.)

Using a query

Queries can be used in two ways. You can copy a query to the Find/Change dialog and execute it there: select one query and press Query to F/C dialog or double-click.

The second way to execute queries is to select one or more of them, then pressing Execute query. If you select more than one query, they are executed in the order in which they appear in the list.

Note: though any format settings defined in a query aren't shown in the script's window, they are nevertheless included when queries are copied to the Find/Change dialog.

Note: to set the change scope (Document, Story, Selection, etc.), set it in the Find/Change dialog. This goes for the options (include footnotes, etc.) as well.

Copy selected queries to GREP styles

You can copy the Find what part of queries to GREP styles. To do so, select all the queries you want to copy, then press Query to F/C dialog. The script displays a dialog which lists all the document's paragraph styles, of which you can select any:

GREP queries overview GREP style

In this example, each of the three selected queries is copied to the three selected paragraph styles. You need to edit the paragraph styles to assign a character style to the GREP expressions.

Rename/duplicate/delete queries

The function of these buttons will be clear.


Press this button to update the list. This is necessary only if you save new queries (or delete existing queries) from the Find/Change dialog while the script dialog is visible.

Clipped lines

The script clips long entries to about 50 characters, as you can see in some cases in the screenshot (for example the query digit_month). This keeps the window manageable and ensures that the Change to column can be displayed.

Displaying long queries

To expand a clipped string, right-click the query in the list. The script now shows a window in which the complete Find what string is displayed:

GREP query queries overview

Press Close to dismiss the window; to load this query into the Find/Change window, press Load. (You'll see queries formatted like this only when you use the GREP editor to format them.)

Version history

21 March 2011: Added some functions: execute selected queries; duplicate and rename queries. Code rewritten to a large extent. (The next logical step is to integrate this script with the query chainer. Don't hold your breath.)

26 October 2010: More integration with the GREP editor. Queries can now be loaded into the editor straight away.

15 July 2010: improved interface; improved copying to GREP styles.

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

Back to GREP page

Back to main script page

Installing and running scripts

Questions, comments? Get in touch