Change case

InDesign's GREP is powerful, but one feature it lacks is case conversion: you can't change the case of what your GREP expression matches. But this can be remedied by a script that acts as a kind of extension to the Find/Change dialog.

The script is an extension of the Find/Change dialog in that it must work in conjunction with it. You first devise a GREP expression that matches the text that you want to change, then you run the script, which takes over from the Find/Change dialog from there on. I'll illustrate it with some examples.

What prompted the script was this scenario. The document I was processing was a bibliography with dozens and dozens of paragraphs with titles of books and articles in which the subtitle always started with a capital, as in Repetition: A Boring Affair. In this title, A should be a; similarly, if a subtitle begins with The, it should be lower-cased to the, and there were a small handful of other function words that should be lower-cased when they were the first word of a subtitle.

Because this can't be generalised you have to look for a capital preceded by a colon and a space, then convert that letter to lower case. Even if you've defined "convert to lower case" to a keyboard shortcut, this is tedious stuff. The script makes things a lot easier. In the example sketched here, the script is used as follows.

1. Define a GREP and make sure that it matches correctly. I needed to find capitals preceded by a colon and a space, which is easy: (?<=:\s)\u. The lookbehind isn't really necessary because naturally when you convert the case of punctuation and white space nothing happens, but I try to make a habit of matching only what is needed.

2. After establishing that the GREP expression matches what you want, run the script. It shows this panel:

grep change case

In the top panel, A > a indicates that we're changing upper case to lower case. If you want to change lower to upper case, simply click the second radio button. You can switch between the modes as you go along.

To apply smallcaps to letters converted to lower case, check the Apply SC box.

The Find, Change, Change all, and Change/find function exactly as they do in the Find/Change dialog; in that sense the script is an extension of that dialog.

Since the script uses InDesign's Find/Change, it respects all settings in the dialog for formatting and search area (include or ignore footnotes, master pages, etc.). The only exception is that what you select at Search: in the dialog (Document, Selection, etc.) is ignored: if you press the script's Change all button, the whole document is processed.


Another example of what the script can be used for is to convert acronyms in upper case to lower case and apply a style to them, either local small caps or a character style. This is just a slight variation of the example given earlier:

1. Define a GREP: \u\u+, and enter the small caps style in the Change Format: pane of the Find/Change dialog.

2. Run the script, using the buttons to change or ignore matches.

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

Version history

28 Jan. 2015: The script crashed in overset text. Fixed.

13 Jan. 2015: Fixed an interface problem caused by CC 2014.

16 May 2012: Rewritten. Fixed memory issues.

Sept. 2010: Posted

Download 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