Site logo

Change fonts script for batch processor

Version with find-change list taken directly from the Excel (XLSX-file)

Here is the latest version of the script and here are the sample files used in the example below.

Version with find-change list taken from the CSV-file

Here is the latest version of the script and here are the sample files used in the example below.

You can prepare a list of the fonts to be changed, say in Excel (optionally), and save it as CSV-file which will be used by the script, or you can edit it directly in the CSV-file using a plain text editor like Notepad (PC) or TextEdit (Mac). The left column is 'Find this', the right one is 'Change to'.

The family name and font style should be separated by \t (which means a tab).

Then you should save it as CSV-file using the Change fonts list.csv name in the same folder where the script is located.

Of course, you can do without Excel and edit the CSV-file in a plain text editor. In this case the left and right elements — find this – change to that — should be delimited by semicolons.

The 'change fonts' script does the following:

  1. changes the fonts in all the paragraph styles
  2. changes the fonts in all the character styles
  3. changes the fonts applied as a local formatting in the same way as the 'find this font and change to that font' feature works in the Find-Change Text dialog box. Note: to illustrate this point, the first paragraph in my sample is set to Letter Gothic Std  and Minion Pro - Bold, Italic and Bold Italic.

In my example the script changes Minion Pro - Bold, Italic and Bold Italic to Myriad Pro (Letter Gothic Std obviously is left unchanged).



The script logs information about the number of styles and instances of local formatting where the fonts were changed in each document.

If errors occur during execution, the script goes on processing without interruption and adds error messages indicating the document name and the guilty line number at the end of the log.

The script is written for the Batch processor so it has no interaction with the user: no fool proofing, alerts, prompts, etc. If an error occurs, it’s silently sent to the log via the global gErrorLog variable. Also, some information is sent via another global variable gErrorLog: e.g. how many styles have been changed, etc. If you’re going to use it as a standalone script, make sure to comment it out these variables like so:

Change fonts script with find-change list hardcoded into the script

Here is the previous version of the script together with' before and after' sample documents (ver. CC 2017).

At the very beginning you'll see the first variable which is the array of arrays containing the names of the fonts in the format:
[ "Find this", "Change to this" ],

Here I used the fonts installed with InDesign to make sure that everybody have them and can test the script using my sample.

Then you can select the script in the Batch processor like so:

See also: