Batch Change Hyperlinks Across a Whole InDesign Document
What if you had to edit 900 hyperlinks in 5 minutes? Or make other huge changes to your document quickly?
Erin wrote:
I have a 120+ page indesign document with approx. 900 links in it. Each hyperlink has tracking built into it, but I need to update all 900 links for the new edition of the catalog. In every hyperlink, I need to change -Fall- to -Winter-. How can I do this without having to manually change every hyperlink?
Well, the best way, of course, is to hire an intern. But the problem with that is that these kinds of changes usually need to be made quickly — like “can you do this by lunch?” — and interns rarely work that fast.
So, option number two would be a script. There must be a way to do this with a script, but for most mortals, it would take a couple of days to figure out how to do it, or to hire a scripter.
So I’m going to go for door number three: Use IDML.

Most people know IDML as a way to save a document so it can be opened with an older version of InDesign, or a way to clean up document corruption that might have crept in. But IDML is much more than that. It is literally a full description of your document, broken down into little XML bits. It’s okay if you’re not into XML; this trick is going to be easy for you no matter what.
If IDML describes my document as XML files, and XML files are just text files, then I should be able to change parts of my document with a simple text find and change, right? Right!
In this case, you want to find and change the hyperlinks. So the first step is to export your document to IDML (File > Export, then choose IDML from the Format pop-up menu).
The trick to editing IDML files is that they’re actually just .zip files. That means you can open them by changing the file extension to .zip! Then you can either decompress them or use a utility to peek inside and let you edit them. I believe Windows lets you simply double-click on them to “open” them like a folder. On my Mac, I use a utility like Springy or BetterZip to open the zip file. (You cannot simply double-click on the .zip file to decompress this kind of zip file on a Mac. Still unsure why that is, as you can on normal zip files.)

The biggest problem with IDML is knowing where the heck to find the data you want to change. One of these days we’re going to have to get Mike Rankin to write that up in an ebook or something. So I simply start opening folders and files semi-randomly until I find something that looks right. In this case, it turns out that all the hyperlinks are stored in a file called designmap.xml, right at the top level of the archive.
To edit it, I:
- drag it out of the archive to some folder on my desktop
- open it in a text editor (on the Mac I use the free and amazingly great TextWrangler, from the same folks who make the even more amazingly great BBEdit)
- search for “-Fall-” and change it to “-Winter-”

- save the xml file
- put it back into the zip archive (replacing the original)
- save the archive
- change its file extension to .idml, and
- re-open it in InDesign.
Erin sent me her IDML file, and I can tell you that the whole process took me about one minute… up to step 8. The last step took several minutes because her file was pretty big and had hundreds of images in it and InDesign had to chew on the IDML for a while.
Note #1: The topic of images is an important one when it comes to IDML. The one thing that is not included in your IDML files is the images themselves. So, when I opened Erin’s file, every image appeared as a gray frame because I did not have access to her links. When she opened it, they all appeared properly because she had the links in the right place. It does take a long time, because every image must be reimported, as though it were being placed.
Note #2: Sometimes a hyperlink shows up empty when you open the IDML file. In that case, you’ll see a red flag in the Hyperlinks panel:

This appears to be a bug in InDesign’s IDML export feature. That is, it’s not the find/change that does it. If you simply export the IDML file and then open it, you’ll get the same errors. In fact, that’s a good test to do before you run the find/change. In general, I’ve found that if you do find empty hyperlinks like this, you simply need to go back to the original InDesign file, double-click the hyperlink, confirm that it’s okay (maybe click a button on or off to say “wake up!”) and then click OK. That seems to clear out the problem. Now run the IDML test again. When the hyperlinks are all working, then you can do your find/change and be on your way.
By the way, in case you’re curious, each hyperlink show up in two or three different places in that xml file. Here’s a couple examples (don’t look if XML makes you queasy… you don’t need to see these to make the trick work):

…

Of course, this trick is not limited to hyperlinks! It’s for any kind of change you want to make throughout a document. If you find other uses, please tell us about them below!
I should also mention that this is possible in CS3 and perhaps even in CS2, using the INX feature (instead of IDML). You can open the INX directly in a text editor (no unzipping required). Branislav Milic wrote a great article about this in Issue 13 (August, 2006) of InDesign Magazine.
This article was last modified on January 24, 2024
This article was first published on November 5, 2010
