• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Batch rename Hyperlinks

Explorer ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

Hi all,

I need to rename a lot of hyperlinks in my InDesign document, is there a quick way to do this... there are 1000's of links that need changing.

it there a way to batch process this? because I can only see an edit function...

I have been told that scripting this would be best, I've never done any scripting in InDesign.

any help would be appreciated

thank you

TOPICS
Scripting

Views

2.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

In CC18 (if not earlier) it is possible to select multiple hyperlinks in the panel and bulk update them to a new URL.

Otherwise, short of finding a script, the other answer would be to go “through the backdoor” using IDML:

https://indesignsecrets.com/batch-change-hyperlinks-across-a-whole-indesign-document.php

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

thank you for your response


I have been trying to change all the hyperlinks in an InDesign document (there are a lot!! need to change "
http://" to "https://" etc etc)

I found this tutorial also

https://indesignsecrets.com/batch-change-hyperlinks-across-a-whole-indesign-document.php

in the tutorial it says to export as "IDML" then open the file as a zip file......inside the zip file is the XML files which can be edited using any text editor..... but you can also "find/replace" across the entire file. which I did.

but after I recompressing the files into an "IDML" file it will not open in InDesign CC 2018

so...

I attempted to export an IDML file then just open it in InDesign (no external editing with a text editor)... but the file still fails to open in Indesign and crashes Indesign

so I assume that editing the file with the text editor is not the problem, but that InDesign will not open IDML files.

---------

You mention that bulk editing the hyperlinks is possible in InDesign CC 2018?

could you please descript this process?

thank you again for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

1. Links before editing:

1.png

2. Edit all selected links:

2.png

3. After editing:

3.png

4. Exported to interactive PDF (and tested in web browser):

4.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

does this apply if the destination are all different?

e.g

http://www.minispares.com/21A1879.aspx

http://www.minispares.com/MSRJM.aspx

http://www.minispares.com/FAM7306.aspx

to

https://catalogue.minispares.com/21A1879.aspx

https://catalogue.minispares.com/MSRJM.aspx

https://catalogue.minispares.com/FAM7306.aspx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

That requirement was not clear, sorry!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Duplicate discussion: IDML file not opening in Indesign CC 2018 

Please keep all in one place.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

thank you for your help,

Sorry for not making that clear

ultimately that is what I need, is there javascript that can do this?

find and replace unique Hyperlinks


I'm not well versed in javascript

can you or someone provide me with some script?

thanks again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

It is amazing what some searching will find:

hypergrep.png

// https://stackoverflow.com/questions/34033528/indesign-script-replacing-all-cases-of-https-with-http-...

Hyperlink.prototype.grep = function(findString,repString, specifiers){

  var r, dests = this.destination, url, dest, n = dests.length;

  if ( !n

  || !findString

  || !repString

  || typeof (findString) != "string"

  || typeof (repString) != "string"

  || ( specifiers && typeof ( specifiers )!="string" )

  ) return;

  r = new RegExp ( findString, specifiers? specifiers:"gi" );

  while (n-- ) {

  dest = dests;

  if ( dest instanceof HyperlinkURLDestination ) {

  url = dest.destinationURL;

  url!="" && dest.destinationURL = url.replace ( r, repString );

  }

  }

}

main();

function main(){

  var d = app.dialogs.add({name:"Replace Hyperlink URL Values"});

  var col1 = d.dialogColumns.add();

  var col2 = d.dialogColumns.add();

  col1.staticTexts.add({staticLabel:"Find (GREP):"});

  col1.staticTexts.add({staticLabel:"Replace:"});

  var find = col2.textEditboxes.add({minWidth:100, editContents:"^https"});

  var change = col2.textEditboxes.add({minWidth:100, editContents:"http"});

  var result = d.show();

  if(!result){

  d.destroy();

  return;

  }

  var grepForFind = RegExp(find.editContents,"g");

  var grepForReplace = change.editContents;

  app.documents[0].hyperlinks.everyItem().grep(find.editContents, change.editContents, "g");

  d.destroy();

}

Thank you Loic!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

ok so that works great for changing


http://www. to https://catalogue.

I thought i would be able to use the same code to remove .aspx from the end of the address

so

http://www.minispares.com/FAM7306.aspxto https://catalogue.minispares.com/FAM7306

i thought changing the code to "" would remove the .aspx but it keeps adding a <space> aka "%20"

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

I have not tested the script yet for .aspx – I’ll have time later…

Until then, try the following for the search with blank for the replace:

.aspx$

Or if you can’t get rid of the trailing white space, try the following for the search with blank for the replace:

\s$

or

 $ 

(word space before the $ sign)

Otherwise we may need to look into capture groups and back references in the find/replace (if supported by the script).

EDIT: Another option could be to find:

6.aspx$

and replace with:

6

(repaeat as required)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

6.aspx$

and replace with:

6

(repeat as required)

OK, that suggestion worked, so you would “only” need to do that 10 times!  :]

___________________

I have just tested capture groups and backreferences, and they do indeed work! So forget the suggestion above, this only needs to be run once to remove the filename extension such as .aspx

Find:

(^.+)(\.aspx$)

or

(^.+)(\..+)

or

(^.+)(\.[^\.]+$)

Replace:

$1


___________________

So my previous suggestions can now be ignored, as we can use a single regex that can do it all!

Therefore to go from:


http://www.minispares.com/FAM7306.aspx

To:

https://catalogue.minispares.com/FAM7306

___________________

Find:

(^http:)(\/\/)(www)(\..+)(.aspx)

or

(^http:)(\/\/)(www)(\..+)(\.[^\.]+$)

or any other “acceptable” viable regex (you do have to test well and know your own data)

Replace:

https:$2catalogue$4

or

https://catalogue$4

___________________

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Hi Stephen_A_Marsh ,

better would be:

^http:

to:

https:

Otherwise you'd change a regular https address to httpss as well.

Also note, that this thread here is related to that one:

Re: IDML file not opening in Indesign CC 2018

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Thanks Uwe, you’re right of course, the tighter the regex the better to avoid edgecases!

Another thread on IDML here:

Re: automatically relinking Shutterstock fpos to hires images

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2020 May 18, 2020

Copy link to clipboard

Copied

LATEST

This looks exactly to be what I need -- but not knowing anythign about scripts, I need some help. I have an Indesign File with Hyperlinks that are all specific to a location with a number. I want to go in and change that number to another number and then save the file. Any help would be great. Thank you -

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines