is now part of CreativePro.com!

Batch Change Hyperlinks Across a Whole InDesign Document

41

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.

findchangehyper1.png

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.)

findchangehyper3.png

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:

  1. drag it out of the archive to some folder on my desktop
  2. 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)
  3. search for “-Fall-” and change it to “-Winter-”
    findchangehyper2.png
  4. save the xml file
  5. put it back into the zip archive (replacing the original)
  6. save the archive
  7. change its file extension to .idml, and
  8. 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:

findchangehyper6.png

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):

findchangehyper4.png

findchangehyper5.png

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.

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • awh says:

    Wow! this is a great tip. I’ll have to give this a try sometime just for fun!

    • Bill says:

      I’m looking to download tomaxxilinkrename or something similar. I cannot find downloads. can you assis?

      • Bill, I’m so sorry but I believe that Tompa (tomaxxi) removed his site last year and is just not responsive to requests for access to those wonderful scripts he had up there, including Link Renamer. Contact me (amarie at indesignsecrets.com) for more info.

  • Jennie says:

    This reminds me of pre-computer days when you got under the hood of your car and could actually make things happen. Change oil or spark plugs, adjust a carburetor, install a new fuel pump, whatever.
    You take the file out of “InDesign” mode and put into “typewriter” mode and you can fix things without having to take the file to a “repair” shop.
    This is great stuff!

  • Excellent, great fix!

    I think between BlatnerTools and IDML editing, you’ve got every InDesign user’s need covered. ;-) Oh, and interns, too. Gotta have the interns.

    Here is Mike Rankin’s Anatomy_of_IDML.pdf that he created in 2008 (when CS4 came out) for his Publicious blog, and he let me include it in the companion files for my New Features in InDesign CS4 title for Lynda.com. It’s a 12-page PDF with each each page dedicated to a screen shot of an IDML file element with call-outs indicating what that type of file contains.

    For the designmap.xml file, he doesn’t mention hyperlinks (just “has a Document root element and references to all the other files in IDML folder,
    indicated by the idPkg namespace prefix”) so maybe it’s time for a v2? Mike? ;-)

  • Mike Rankin says:

    The only problem with this solution is that it’s too magical. People will come to think that you can fix any 900 problems in a snap.

    Seriously though, this is a great use of IDML. What would be even cooler is if you could run that Find/Change on the IDML archive so you didn’t have to know which file the hyperlinks were in. I have never been able to get Oxygen to do that, though I dearly wish I would. If we could do that, the utility of IDML would be kicked up to a whole new level.

    As an alternative, you could use Shane Stanley’s totally wicked drag and drop IDML script to convert the IDML file into a folder directory, then perform the Find on the top level folder and include recursive directories, then convert back to and IDML file. Oxygen and BBEdit can do this. https://creativepro.com/drag-and-drop-applescripts-for-epub-idml-etc.php

  • filejockey says:

    Tried it. Nice. I found I didn’t have to change the extension from idml to zip. Just drag the idml file onto Springy, which expanded it as any archive.

  • @filejocky: You’re correct; I should have mentioned that. Many utilities (such as Springy and BetterZip) can open the .idml file without changing its name. As Mike R. mentioned, Oxygen XML editor can also do this to great effect.

  • Low jackson says:

    I’ve had a similar problem today, having built a 52 page product brochure, Ive now been asked to produce a PDF version with Hyperlinks on all the 300+ product names.
     
    The client is able to supply a spreadsheet of all the product names and URL in columns (XLS). Is there a way to find the Product Name in the doc and add the URL in to the hyperlinks panel? I was thinking a script but maybe editing the idml may be easier.

  • Mike Rankin says:

    Anne-Marie-

    I’d love to do a V2 and post it here. Just have a few other things in the Mike queue ahead of that…

    Maybe I can realize my dream of creating IDML trading cards. Each element gets its own card, 12 cards in a pack with a stick of bubble gum. Collect ’em all!

  • Harbs says:

    Hey David,

    Did I hear “script”? :D

    (Took me at most 10 minutes…) ;)

    https://in-tools.com/downloads/indesign/scripts/ReplaceHyperlinkUrlValues.jsx

    Harbs

  • Harbs, that is seriously… I don’t know… either great (from the user perspective) or evil (from the perspective of putting the kabosh on my great tip). But I think the former trumps, so thanks! Cool.

  • Harbs says:

    Hi David,

    Evil? Me??? :evil:

    Seriously, I don’t think my script detracts from your post at all. You illustrate very well how powerful IDML is. It enables doing ‘script-only” stuff even for non-scripters.

    Of course anything that can be done using IDML can be done by scripting, but sometimes even with scripting, using IDML is the best way to go about it… Bottom line is, you can’t always expect one of us scripting geeks to stop by and offer our services! ;)

    Another really cool thing about IDML, is it can show you how the scripting hierarchy works. All IDML properties are in fact scripting properties and have the same names…

  • Oh, I truly appreciate it, Harbs. No problem at all. I only mentioned “evil” as I know you like the term and you’re clearly the polar opposite. :)

    But you’re very right that it doesn’t detract. The important thing is that people understand the idea of idml… and now understand the power of scripting!

  • Rick Gordon says:

    Can anyone comment about any possible risks round-tripping from IDML? Round-tripping from IDX was risky business, as some structural details could be lost, sometimes without the user really being aware of the loss until too late. Assuming that you’re not screwing up at the edit phase, will 100% of the content and structure survive the round trip?

  • Harbs says:

    @David, That “evil” smiley was tongue-in-cheek. I didn’t take you first comment to be anything else… ;)

    @Rick, IDML is supposed to be foolproof, and the fact it’s based on the scripting model should theoretically make it so. However, I have seen some IDML round-trip mess-ups, but those were generally with non-standard docs. It’s definitely a good idea to check after doing a IDML roundtrip — especially with suspect areas of the doc…

  • Harbs says:

    Just one more comment relating to IDML round-tripping: If you do find any problems after round-tripping IDML, please report it to Adobe as a bug. They treat IDML round-trip problems very seriously…

  • Colin Weston says:

    On my Windows machine I couldn’t get the round-trip to work – got a long error message on attempting to open the modified, re-archived and re-named file in InDesign. Tried various compression softwares including WinMount and jZip. Then tried the script and that worked perfectly. One out of two!

  • Phyllis says:

    Awesome article, thanks!!!!!!

  • Joslyn says:

    Just last week, I was looking for a way to remove Paragraph Style Groups from a document, and this article made me think that maybe IDML would help. As it turns out, it could work if one were patient enough to not only strip the Paragraph Style Group names from the Styles.xml file, but also from each story in the Stories folder. No thanks.

    But, this did lead me to explore the same possibility in an INX file, and it works great. You just 1) search for the name of your style group (for example, “Headlines”) and delete the line that contains it, and 2) search for the name of your style group followed by a colon (so, in this example, Headlines:) and replace it with nothing. Repeat this for all your style group names. Open the INX back up in InDesign, and your paragraph styles are no longer in those pesky folders you once thought were a good idea.

  • Mike Rankin says:

    Joslyn-

    Nice work! This is an instance where the single file of INX is easier to work with than an IDML archive.

    The drag and drop script I linked to above could also help in this situation. Use it to convert the IDML into a set of nested folders. Then use an app that can find/change in recursive directories, and it saves you from having to track down stuff in all those pieces of an IDML file. It’s also good for folks with CS5, who can’t export INX.

  • Very similar to Microsft Word’s docX ;-)

  • Me says:

    @david – AFAIK Mac uses the mime type header to identify files – not the extension – which is why a file renamed to zip is not treated the same as one that was originally a zip file.

    @mike – search and replace text inside archive – I think Seeker (Win, free) will do that:
    https://www.veign.com/application.php?appid=104

    Thanks for tips all!

  • I need to ask a question before I try this.

    I have created a an Indesign file (CS4), with about 90 hyperlinks to other pdf files on my hard drive. I am outputting the final document as a pdf.

    I want to be able to give this document (with the linked pdf files) on a USB thumb drive or on a CD.

    My problem seems to be that when Indesign creates the link path is it to the exact location of the file at the time the link is created.

    Is there a way to embed the linked pdf files into the final pdf ?

    If not is there another solution ???

    Thanks in advance.

  • @Damian: No you can’t embed pdfs into the final, based on links. You could try using relative links: https://creativepro.com/making-relative-hyperlinks-to-files-in-indesign.php/comment-page-1
    But it’s kind of wonky.

  • that worked ! thanks.

    Frustrating that the final PFD now treats the links as URLs and there for has a bit of a security freak out each time you try to open one – but it works so thats great.

    Thanks again

  • Murray says:

    I’m using InDesign CS5 (v7.0.4) on a Mac.

    I can’t get the last step (step 8) to work. I can open the IDML file, use TextEdit to make changes, re-zip using the Mac OS feature (1 try) and using Stuffit Deluxe (2nd try), and change the resulting .zip extension to .idml. When I try to open the new idml file I get an InD message saying it can’t do it (“InD may not support the file format, a plugin may be missing, or the file may be open”).

    Any advice would be appreciated. Is there any reason not to use TextEdit rather than the programs mentioned above?

  • Murray Coppold says:

    Follow-up comment. It’s the zipping and changing file extension that’s the problem.

    If I export my InD CS5 document as IDML, expand it using Stuffit Expander, then immediately re-zip it using Stuffit Deluxe (not opening or altering the folder in any way), change the zip suffix back to IDML, InDesign gives the above-mentioned error and can’t open the document.

    This is a simple one-page file with 10 hyperlinks and only a couple of icons as graphics. The exported IDML file is 147K. It happens on my work and my home Macs – completely independent machines, up-to-date and running fine otherwise.

  • @Murray: Perhaps try zipping some other way? What’s wrong with right-clicking (or Control-clicking with a one-button mouse) and choosing Compress? Then change the file extension to .idml.

  • Murray says:

    David wrote: What?s wrong with right-clicking (or Control-clicking with a one-button mouse) and choosing Compress?

    That’s exactly what I tried first. When that didn’t work, I went to Stuffit as a second way of zipping the file in case there was something flaky with the Mac OS way. Neither will open when renamed to IDML, even when there has been no change to the enclosed files themselves.

    I’d love to get this to work, as I am faced with clients who need batch changes.

  • Jongware says:

    Murray (and David!): The Mac doesn’t Play Nice when compressing files. It automatically adds loads of invisible stuff, which it thinks might help the poor Mac next door unpack those same files — except that I’ve never had any problem decompressing files that were compressed on another system. So it seems it’s just one of those Apple issues.
    Besides: I might have read somewhere that the order of compressed files is important as well.

    Check out this post by Mike Rankin: Drag and Drop AppleScripts for EPUB, IDML, etc.. I’ve used these little scripts, and what can I say? It works a treat!

  • Murray says:

    Jongware: Thank you once again for helping me by pointing out the article by Mike Rankin about the Shane Stanley Applescripts. I tried the IDML one and was able to open an IDML, edit it, and return it to IDML which successfully opened in InDesign CS5.

    This has got me around the zip problem mentioned above.

    Thanks again to everyone who has helped with this problem: Jongware, David, Harbs, Mike and Shane.
    What a great community!

  • shell says:

    This seemed like a great solution for me until I found the file(s) with the link paths I needed to edit…. mine is not simply the designmap. Instead, there is a folder with every spread as its own xml, and that is where the link paths are. There are a LOT of spreads in this doc…. It will take nearly as much time to open & edit the xml files as it will to just relink all the files “by hand” in the actual indesign doc.

    Yes, I’m just whining because this solution didn’t work for me :/

  • David F says:

    There is a very simple, inexpensive program to allow bulk update of link in PDF files available here https://www.tucows.com/preview/1592099/PDF-Hyperlink-Updater
    It has a trial mode so you can test

  • Do you happen to have, or know of, a way to scan a PDF, change the hyperlinks, and re-save the PDF? Alternatively, a tool to “unlink” the hyperlinks in PDF?

    John Russell Burgreen III
    Homeless Marine @ Ready to Work Boulder
    4747 Table Mesa Dr, Boulder, CO 80305
    https://bit.do/bldr

  • Gabriel says:

    I’d like to add a tracking code to all the hyperlinks on the document…any suggestions

  • Drew C says:

    This seven-year old tip worked perfectly for me. Had a 32-page doc with scores and scores of outbound links to PDFs which were moved from one server to another, worked like a champ! Thank you!

  • Candice says:

    Hi. I am having trouble opening the idml file from InDesign after doing all the previous steps. I have InDesign CC 2017. It says

    Cannot open the “filename.idml”. Adobe Indesign may not support the file format, a plug-in that supports the file format may be missing, or the file may be open in another application.

    Hope does one open an idml file in InDesign. I do not have a previous version of InDesign.

    • Candice says:

      I figured out what I was doing wrong! Once the designmap.xml has been extracted one MUST edit it with an xml editor like Dreamweaver and not with an editor like Notepad (which is what I was doing – silly me).

      When I opened the xml file in Notepad, did the find/replace, saved it and replaced it in the zip file, InDesign did not like it only because of the xml file that had been replaced as it had been edited in Notepad.

      I finally opened the designmap.xml file in Dreamweaver, edited it there, saved it, replaced the designmap.xml in the zip, changed the file extension back to .idml and finally InDesign (as well as I) was happy! :)

  • >
    Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo