GREP Replace From Spreadsheet

Script for Adobe InDesign
Latest update 4/30/2022, version 2.1

The script reads a spreadsheet of GREP patterns and their replacement, and replaces all matches in the active document. A virtually unlimited number of replacements are performed in a single operation rather than countless visits to the InDesign Find/Change dialog.

  • Match whole words only
  • Ignore case
  • Keep capitalization
  • Confirm each change
  • User-configurable localization

To find and change text, see Find Change From Spreadsheet
For processing multiple documents, see Find Change Multi Doc
For Illustrator, see Find Replace From CSV

Download
GREP Replace From Spreadsheet

FREE to download
Please make a contribution

Many scripts are free to download thanks to the support of users. Help me keep developing new scripts by supporting my work. Click any one of the buttons below to make a contribution of any amount. Thank you.

× Stripe

Choose an amount to contribute.
Thank you for supporting my work.

How-to Video

THIS IS AN AD. Beware of anything in the ad artwork that resembles a 'DOWNLOAD' button meant to confuse you into thinking it downloads something from this website. It does not.

Before using the script

The script requires a spreadsheet of GREP patterns and their replacements, saved as Comma Separated Values (CSV format). The spreadsheet must have at least two columns, one for the GREP pattern to match, and another for its replacement.

GREP Replace From Spreadsheet data example

The first row is the header, which identifies the contents of each column. In this example, the column headers are Find and Change. These columns could just as well be labeled “match” and “replace,” or any other desired labels. The precise column labels, or their order, are not important, and there is no harm in extra columns. Which column is the GREP pattern, and which is its replacement, are selected in the script interface.

How to use the script

The interface is divided into two sections: Data file and Options. Click the File button to select the CSV file, set the options as desired, and click the OK button to begin. The user is notified when processing is complete, or if an error occurs.

Data File (CSV)

Delimiter — the character that separates columns of the data file. The default is comma, normal in the United States. Some European countries use semicolon rather than comma. Select the delimiter relevant to your region of the world.

File — select the CSV data file, then the column drop-down lists (next) are loaded with the columns discovered in the data.

Column find — select the column of GREP patterns to match.

Column change — select the column of replacement text.

Options

Ignore hidden layers — when enabled and a match is found on a hidden layer, the text is ignored, and no change is made. When disabled and a match is found on a hidden layer, if the option Confirm each change is enabled, the layer is made visible and the confirmation dialog appears as normal. Otherwise the change is made and the layer remains hidden.

Whole word — text matches only when whole words. If disabled, text matches also when words contain the text. For GREP, this option is achieved by wrapping the GREP pattern in \< and \>, which indicates whole word. The same could be done to patterns in the data and get the same result. The option exists to simplify the data file if desired. IMPORTANT: do not use this option if GREP patterns in the data file already contain the command for whole word. Doing so prevents patterns from matching.

Case insensitive — text matches regardless of upper or lower case, or any combination of either. For GREP, this option is achieved by prefixing the GREP pattern with (?i), which indicates case insensitive. The same could be done to patterns in the data and get the same result. The option exists to simplify the data file if desired. IMPORTANT: do not use this option if GREP patterns in the data file already contain the command for case insensitive. Doing so prevents patterns from matching.

Keep capitalization — available when the option Case insensitive is enabled. When the text found is capitalized, the change is capitalized even if not capitalized in the spreadsheet. If the text found is not capitalized, the spreadsheet data is used as-is. This is useful for words that are normally not capitalized, but could appear at the beginning of sentences, requiring capitalization. Without this option, such cases require two separate find/change pairs, one capitalized, another not, and processed with the Case insensitive option disabled, otherwise risk the beginning of sentences becoming lowercase.

Confirm each change — if enabled, the display is magnified to the value for the option Zoom (next), to better show the changes to confirm. A confirmation dialog appears on screen, described in the next section.

Zoom — the percentage to which the display is magnified when processing begins. This allows the user a closer look at selected text to better judge if changes are acceptable.

Confirm each change

Each match is selected in the layout, and a confirmation dialog displays the proposed change above a series of buttons:

GREP Replace From Spreadsheet confirm

Zoom: - / + — click minus to decrease zoom and show more of the page. Click plus to increase zoom for closer inspection of the change to confirm.

OK — the selected text is changed as indicated, and the next proposed change is selected.

OK all — the selected text and all remaining matching instances are changed without further user intervention. This applies only to the current find/change pair. When the next find/change pair begins processing, the confirmation dialog is again displayed. This repeats until all find/change pairs are processed.

Skip — the selected text is not changed, and the next proposed change is selected.

Skip all — the selected text is not changed and all remaining matching instances are ignored. Processing resumes with the next find/change pair and again the confirmation dialog is displayed.

Cancel — processing ceases without further changes. Any changes previously accepted remain. If desired, the Edit menu item Undo restores the document to its state prior to launching the script.

The confirmation dialog appears centered on screen and near the top of the window. If the dialog obscures the layout, it may be moved to another location on screen, even to a secondary display. The dialog will maintain its new position until the next launch of the script.

If any story has overset text, it is not possible to show the proposed change because it is hidden off-screen in the overset text. In this case, a warning is displayed and the user has the option to continue regardless, or decline and remedy the overset text before trying again, the recommended choice. Then each change is visible and can be confirmed.

Language

By default the script language is US English, which does not require further download or configuration. To have the script interface display other languages, choose from the available languages below. Download and copy the .i18n file to the script folder alongside the script. When launched, the script detects the language file and displays interface text in that language. If your language is not listed, download the English file and translate it. The file is plain text formatted as JSON, containing interface text in English, and a second value for its translation, which for the English file is the identical text. Copy the file and rename it to replace “en” with the relevant code for your language, then edit the file to change each line’s second value to the translation in your language. For more detailed instructions of how to edit and install i18n files, see How to Localize Scripts.

English: grep-replace-from-spreadsheet-en-i18n.zip

× Stripe

Choose an amount to contribute.
Thank you for supporting my work.

Download
GREP Replace From Spreadsheet

License details included in download

For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.

Also available for hire to program custom solutions. Contact William for more information.

IMPORTANT: by downloading any of the scripts on this page you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.