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

Find and Replace text in Hyperlink URL?

New Here ,
Nov 03, 2022 Nov 03, 2022

Hi all,

 

I'm trying to figure out how to find and replace the base part of a URL hyperlink in an Indesign file with another domain.  So for example www.example.csod.com/12345 becomes www.somethingelse.csod.com/12345

 

I have an Indesign catalog with hundreds of hyperlinks that will be breaking in a couple months with a domain change and I want to make this transition as painless as possible.

 

Now I've seen this question answered with information about running a script, but I need someone to explain this to me as if I know nothing about scripts (because I don't haha).

 

Thank you in advance!

TOPICS
Scripting
1.5K
Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Based on your example a GREP search would do

 

w{3}\.\K.+?(?=/)

 

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Can you provide very dumbed down instructions with pictures?

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Edit>Find Replace

Go to the GREP tab

 

Copy that text into the Find GREP field

https://helpx.adobe.com/ie/indesign/using/find-change.html

 

 

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Ok here I am, I'm in the Find/Change menu in the GREP tab, I pasted the text  into the Find What field then what?  Where do I put the previous url base, where do I put the new one?  What button do I press after that?


1.pngexpand image

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Great.

 

In the change to field you can insert the replacement text.

 

Then press find next. If it's a match for what you want you can select Change.

 

 

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

I just ran a test and it didn't work.  All it did was highlight a part of one url that's in some body text, it's not looking at the hyperlinks.

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Is it highlighting the portion of the url you want to change?

 

In the Replace field you need to insert the text you want it to change to.

 

At this point it seems like it would be beneficial for you to look up some video tutorials on how to do a find/change using InDesign.

 

 

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

No it is highlighting text in the document, I need to find and replace the base part of a hyperlink.

 

I'm here in the Adobe support community to get help lol.  I already tried searching how to do this in videos and I'm totally lost.

Translate
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 ,
Nov 03, 2022 Nov 03, 2022

Hi @Becca26946798d5iz,

Make a sample document for us to test it and then send the solution your way. Since you have little experience in excecuting find/replace queries it might be possible that some instruction is getting misinterepreted or missed and hence you are not seeing any results.

-Manan

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

Thanks Manan, here's a sample document for you.  

Translate
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 ,
Nov 04, 2022 Nov 04, 2022
quote

… I'm trying to figure out how to find and replace the base part of a URL hyperlink in an Indesign file with another domain.  So for example www.example.csod.com/12345 becomes www.somethingelse.csod.com/12345

…


By Becca26946798d5iz

 

Sorry if I misunderstood you - but do you really need a grep for that? A simple text search
find:

.example.

replace:

.somethingelse.

should be quite sufficient? Or not?

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

No, I couldn't get find and replace to to work for a hyperlinked url, just text in the document.

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

Here's a link to an InDesign article that I think is what you are looking to do in your document.

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

Janine

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

AHHH - penny finally drops! You also want the hyperlink itself to change... oh my! 

Thanks for clarifying further, I didn't consider this possiblity.

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

Ok, now I understand. You do not only want to change the text of one (several) existing hyperlinks but also the hyperlink targets of the hyperlink. This is not possible with search and replace. You need a script for that.

Translate
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 ,
Nov 04, 2022 Nov 04, 2022

You can change the text of the hyperlink and the destination URL of the hyperlink something like this:

 

I tried the example in your first post and it works (initially just the first hyperlink in the document - written quick and dirty and not optimised).

var hyp = app.documents[0].hyperlinks[0];
if ( hyp.destination && hyp.destination.hasOwnProperty("destinationURL") && hyp.destination.destinationURL.length > 0 ) {
var destTxt = hyp.source.sourceText.contents;
var dest = hyp.destination.destinationURL;
var newDestTxt = destTxt.replace("example", "somethingelse");
var newDest = dest.replace("example", "somethingelse");

app.documents[0].hyperlinks[0].source.sourceText.contents = newDestTxt;
app.documents[0].hyperlinks[0].destination.destinationURL = newDest;
alert ("hyp[0] updated");
} else {
    alert ("no hyp[0] destination URL found");
    }

 

You just have to loop through all the hyperlinks and do error management. Maybe it can be simplified, but I don't usually write scripts for Indesign - there are a lot of people who can do it much better than I can.

 

If that works for you

Have fun

😉

Translate
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 ,
Nov 04, 2022 Nov 04, 2022
LATEST

@Becca26946798d5iz please try the script shared so graciously by @pixxxelschubser and let us know if this is what you need. If the idea is on the right track then we can work on extending the script if you need help in that aspect.

P.S.:- If you are new to using scripts and wonder how to use them, see the following article

https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/

-Manan

Translate
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