Find Replace From CSV
Script for Adobe Illustrator
Latest update 12/5/2023, version 2.5
The script reads a spreadsheet of find/change pairs and replaces each instance of matching text in the active document. A virtually unlimited number of find/change pairs are performed in a single operation rather than countless visits to the Illustrator Find and Replace dialog.
- Match text or GREP
- Whole words only
- Ignore case
- Keep capitalization
- Confirm each change
For InDesign, see related scripts:
Find Change From Spreadsheet
GREP Replace From Spreadsheet
Find Change CSV Multi Doc
How-to Video
Before using the script
The script requires a spreadsheet of find/change pairs, saved as Comma Separated Values (CSV format). The spreadsheet must have at least two columns, one for the text to find, and another for its replacement. To remove text, make the change column blank and the text found is replaced with nothing, the same as deleting it.
The first row is the header, which identifies the contents of each column. In this example, the column headers are Find and Change. Using this data file, the script changes colour to color, afternoon is replaced with evening, and every instance of dog becomes cat.
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 text to find, and which is its replacement, are selected in the script interface.
In each row, the values for find and change can be either text or a regular expression (GREP). Rows may differ even; some text, some regular expressions. To inform the script that the text to match is a regular expression, begin and end the expression with forward slashes. Flags after the trailing slash are ignored, as the script always replaces all instances (g flag for global) and whether to ignore letter case (i flag for insensitive) is controlled by the script interface option Case insensitive. If the expression includes any capture groups, the normal placeholders are recognized in the replacement, i.e. $1, $2, etc. In the rare case the text to find happens to begin with, and end with a forward slash, there is no choice but to use a regular expression, because the script always sees this as the signal for a regular expression. In that case, construct a regular expression that matches the desired text but escapes the slashes and any other punctuation characters that could be interpreted as regular expression commands.
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.
Section 1: 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 used in 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 text to find.
Column change — select the column of replacement text.
Section 2: Options
By default the script includes changes on hidden and locked layers. Use the next two options to ignore either if desired.
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.
Ignore locked layers — when enabled and a match is found on a locked layer, the text is ignored, and no change is made. When disabled and a match is found on a locked layer, if the option Confirm each change is enabled, the layer is unlocked and the confirmation dialog appears as normal. Otherwise the change is made and the layer remains locked.
Whole word — text matches only when whole words. If disabled, text matches also when words contain the text.
Case insensitive — text matches regardless of upper or lower case, or any combination of either.
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, each change is selected in the document and a confirmation dialog appears on screen that displays the proposed change above a series of buttons:
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.
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.
Find Replace From CSV
Change log: find-replace-from-csv.txt
For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.
IMPORTANT: scripts are developed for the latest Adobe Creative Cloud applications. Many scripts work in CC 2018 and later, even some as far back as CS6, but may not perform as expected, or run at all, when used in versions prior to 2018. Photoshop features Select Subject and Preserve Details 2.0 definitely fail prior to CC 2018 (version 19) as the features do not exist in earlier versions. For best results use the latest versions of Adobe Creative Cloud applications.
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.
IMPORTANT: fees paid for software products are the purchase of a non-exclusive license to use the software product and do not grant the purchaser any degree of ownership of the software code. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all software products regardless of the inspiration for the software product design or functionality.