You designed an InDesign document, using a number of images, and you want to replace those image links with new source files whose names differ from the previous following a predictable pattern. This script will enable you to use InDesign's "Find/Change" dialog box to replace those links.

Example 1: your page layout was achieved using 640-pixels versions of royalty-free pictures from Pixabay, ending with "_640.jpg", and now you made up your mind at least to register to this site in order to be able to download those same pictures in full resolution, the downloaded files have the same name as the previous ones without the "_640" suffix. To replace the links you just need to

open the dialog box Find/Change > Text
type in:
Find what: _640.jpg
Change to: .jpg
Run the script
Select the folder to search in for the links
The script then displays the search results in a window, in many tabs if the result count is high. You can then optionally uncheck some links that you don't want to replace
Validate the window ("OK" or "Replace all checked links" depending on the script version) > Checked replacements are processed.

To proceed the reverse modification, replace all full-res versions with the 640px versions:
Find/Change > Text
Find what: .jpg
Change to: _640.jpg
Run the script, etc.

find change links indd 002 en

Example 2: you still have lower resolution pictures from Pixabay to replace with their full-res versions, but this time you have a mix of 640px, 1280px and 1920px versions (ending with "_640.jpg", "_1280.jpg" or "_1920.jpg"). This time your will have to use:

Find/Change > GREP
FindWhat: _\d+\.jpg
Change to: .jpg
Run the script, etc. (Demo)

Hence the benefit of using the existing Find/Change GREP dialog box that allows you to use the Special Characters icon @ to help you to build your regular expression, because not everybody knows by heart the GREP syntax.

To process the reverse modification restoring the different lower resolutions pictures in place of the full-res ones:

Find/Change > GREP
FindWhat: \.jpg
Change to: _\d+ \.jpg
Run the script, etc.

Notice that in this last specific case "Change to" is also a regular expression, which is not normally expected in InDesign's Find/Change GREP dialog box, but this will enable the script to understand that he must replace the images with others whose ".jpg" extension is preceded by an underscore and one or more digits[1].

The script could then find multiple matching files, if for example your startup image is named chihuahua-2101644.jpg and the search folder contains both chihuahua-2101644_640.jpg and chihuahua-2101644_1920.jpg: for this reason the results are shown in dropdown lists (actually even for single match) in the results window, allowing you to chose before validating the replacements.

The "Include locked layers and items", "Include hidden layers and items" and "Include master pages" options from the "Text" and "GREP" tabs will be taken into account,
The "Case sensitive" option from the Text tab will be taken into account also for the GREP search.

    The new version 13:
  • Better deals with some accented characters on Mac OSX that previously were sometimes not recognized because of the composite unicode (NFD) encoding of the file system (modified after the problem was reported by Andreas Rößner, head of a design studio in Munich).
  • Proposes, if any, to look for the links to replace also in the sub-folders within the selected folder (modified according to a request by Joke Wouters).
  • Unlike in the previous versions, now a single version is provided, displaying a "palette" window that enables you, from within the results tabs, to select each link, showing where it is located, and decide optionally to replace it individually in order to see the difference, or to replace all checked links at once. Tested without problem on many InDesign versions including an old CS5.5.

[1] In example 2 I used the most easy to understand syntax for GREP beginners, but we may also use

Find what: _\d+(\.jpg)
Change to: $1

and the reverse search

Find what: (\.jpg)
Change to: _\d+$1

"Change to" is then an unusual regular expression including a submatch $1 from a previous regex — hybridization correctly interpreted by my script. Entire match $0 also works but will be replaced with its javascript equivalent $&

6 thoughts on “Use the Find/Change dialog box to replace links in InDesign”

  1. The mediabox popup showing my animated gif demo seems to often crop it depending on your screen size and browser window size, so I also added a ([u][url=]→ Demo[/url][/u]) direct link to it.
    Note: the text colorization is post-processed on the demo movie to highlight and clarify the regular expression and show what it matches, but you won't see text colorized like that in your InDesign interface when you will use the script.

  2. Awesome Script! I was looking for this for a long time.

    Works great! A very powerful time saver.

    Thanks a lot.


  3. Hi!
    This is exactly what I'm looking for except that the script needs to search subfolders also. Can I change that option in the code? Or is that too hard?

    I have multiple files to find/change but there divided into subfolder.

    Can you help me?

    1. I added that option in the new version 13. Best regards — Frédéric Robin.

  4. Perfect! Just what I needed.


  5. Hello quick question here. I just want to update a link, to a new one. Is there any easy way of doing this?

Leave your comment

In reply to Some User



An original idea from Loic Aigon, designed by Eddy.VH. It 's a scripts library for Desktop Publishing Adobe products. Find Javascript for Photoshop, Illustrator, inDesign and Acrobat or ATN scripts ( Photoshop actions ) you need.