Changing Numbers to Words with a Script

A while back, David wrote a post on a cool script from Jongware that allows you to have page numbers written out as words instead of numbers. It got me to thinking about how you might also convert numbers in regular text to words, and it turns out that there’s a script for that too—and every InDesign user already has it. It’s the venerable Find/ChangeByList script that comes with InDesign.

To make the script change numbers to words, you first need to edit the text file that the script references. You can find this text file in InDesign’s Scripts panel in Samples > Javascript > FindChangeSupport. Right-click on the file and choose Reveal in Finder/Explorer.

20150615-numberscript-1

Duplicate the text file and stash the unaltered copy in a safe location to serve as a backup.

Then open the original file in a text editor of your choice and replace the default queries with new ones that change numbers to words. You can target text formatted with specific fonts, paragraph/character styles, or only on visible layers, etc.

20150615-numberscript-2

For a complete guide to using the Find/ChangeByList script, check out Cari Jansen’s article in InDesign Magazine issue 26, and the InDesignSecrets podcast 90.

With the help of the script, you can instantly change something like this:

20150615-numberscript-4

Into something like this:

20150615-numberscript-3

If you need to replace double-digit numbers, be sure to include the option wholeWord:true, otherwise things like “12” will be changed to “onetwo”.

Screen Shot 2015-06-15 at 11.21.55 AM

In other cases, you can get around some problematic replacements by telling the script to process double-digit numbers before single-digit numbers.

In general, the script won’t mess up things like phone numbers, dates, serial numbers, and page ranges. But watch out for things like OpenType fractions, decimals, numbers followed by an underscore, and ordinals, which will require a separate line in the text file:

Screen Shot 2015-06-15 at 11.21.01 AM

Bookmark
Please login to bookmark Close

This article was last modified on July 25, 2019

Comments (5)

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading comments...