is now part of CreativePro.com!

Changing Numbers to Words with a Script

5

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

Editor in Chief of CreativePro. Instructor at LinkedIn Learning with courses on InDesign, Illustrator, Photoshop, GIMP, Inkscape, and Affinity Publisher. Co-author of The Photoshop Visual Quickstart Guide with Nigel French.
  • rich says:

    Interesting and clever stuff.

    There is a similar thing here.
    https://www.creativeprogression.com/inflationary-english-grep/

    Inflationary English: A GREP Tribute to Victor Borge
    by Paul Erdman on May 19, 2014 in Featured, Front Page, InDesign

  • Mike Rankin says:

    That’s cool. Thanks for sharing it Rich. Here’s the link to Victor Borge’s video, which is pretty funny. https://www.youtube.com/watch?v=YY6kElOYcd8

  • A. A. Ron says:

    I was thinking of using this a few months ago, but I have to be very selective of what numbers become words in the text I work in so I found an AppleScript that I modified and then, with an Alfred workflow, I assigned it a keyboard shortcut/hotkey. Works like a charm and only runs on selected text.

  • Jacob Deng says:

    Pretty cool! Now I can use “wholeWord” feature to change my numbers.

  • >