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

Relink images with different names (only first part)

Community Beginner ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

Hi all, i have a problem: i want to relink in about 500 photo's i've add to Indesign. Because of a HD crash i need to link to a back-up, with the same files, but different names. There is only a agreement on the numbers.

 

For example:

- File-name in Indesign:  dscf7618_45503705025_o.jpg

- File name in the backup file: DSCF7618

 

The second part after 7618_.... -> is totally random. So the only match is the number.

 

Is there a possibility to add this in a script? And how can i run this the best possbile way?

TOPICS
Scripting

Views

496

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

correct answers 1 Correct answer

Advisor , Jan 02, 2021 Jan 02, 2021

Hello Creativehub2324 !

 

Give the below script a try...........it should work for your exact situation and file naming convention.

All you'll need to do is install the script in Indesign and run it!

 

Follow the instructions in the link below to install the script.

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

 

 

 

 

var doc = app.documents[0];

sourceFolder = Folder.selectDialog("Select a Source Folder");
if (sourceFolder != null){
}else{
exit();
}

...

Votes

Translate

Translate
Community Expert ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

Give this script a try... It allow the use of find/Change dialog for relinking graphic. By using a suitabel GREP you could probably do it easily.

https://www.scriptopedia.org/en/js-indesign/189-find-change-links-in-indesign.html

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 Beginner ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

@Jean-Claude Tremblay  - thanks, and it looks something what can help.  But i run into a little problem / question.

 

In the instructions they use this:

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

 

--> But what do i have to do in my case? 

 

I guess it is a little more complex. Because i have random Indesign Files in my document, like: dscf7618_45503705025_o.jpg, and want to change them to Files (1) into a different Folder on my computer with (2) a different name.

 

What should i do?

 

 

 

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 ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

Try this:

Put this in your GREP Find window, than execute the script. It will ask you to locate your folder, than if you want to search inside sub folder, click yes.

Find: (.+?)_.+\.jpg
Change: $1.jpg

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 Beginner ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

@Jean-Claude Tremblay  I tried, but there is a pop-up: "can't find a match". Same as the previous code. I also can't select a folder or sub-folder.

 

Look's like this won't work....

 

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
Participant ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

This looks like what you need. It's just not very user friendly. I just repleciated your file name and created them in subfolders. I then just select the master folder, the script then asks if I wanted to to include sub folders in which I clicked yes.

If you are still having problems with this can you take a screen shot of the Can't find a match error.

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 Beginner ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

@tacoeater, what do I have to do, or do I do wrong? 

 

1. I installed the script 

2. I open the search and change pop-up

3. I select the GREP option

4. I put this in the find and change boxes below:

 

Find: (.+?)_.+\.jpg
Change: $1.jpg

 

5. I press 'next' to run the script. 

6. Error bevause there are no matches. 

 

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
Participant ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

Ok I think we got it.

Go to windows > Utilities > Scripts. Select the script, right click it and run script.

The GREP window doesn't do anything, it's just for putting in the search string. When you run the script you'll be able to select the folder that contains the images or subfolder of images that you want to change. It must then look at whats in the find and replace grep fields for its matches.

 

Like I said before this isn't very userfriendly.

 

Hope this helps.

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 ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

5. Go to Window > Utilities > Scripts and double click the script (if you have installed correctly).


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
Advisor ,
Jan 02, 2021 Jan 02, 2021

Copy link to clipboard

Copied

Hello Creativehub2324 !

 

Give the below script a try...........it should work for your exact situation and file naming convention.

All you'll need to do is install the script in Indesign and run it!

 

Follow the instructions in the link below to install the script.

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

 

 

 

 

var doc = app.documents[0];

sourceFolder = Folder.selectDialog("Select a Source Folder");
if (sourceFolder != null){
}else{
exit();
}

var myFilesToLink = sourceFolder.getFiles();

try {
for(var i = 0; i < doc.links.length; i++){ 
  if (doc.links[i].status == LinkStatus.LINK_MISSING){ 
  var myMissingLinks = doc.links[i];
  var myMissingLinksName = doc.links[i].name;
  var myMissingLink = myMissingLinksName.replace(/\_.*/, '');


    for (var f = 0; f <myFilesToLink.length; f++) {
     var myBackUpFile = myFilesToLink[f];
     var myFilesToLinkName = myBackUpFile.name.toLowerCase();
     
        if (myFilesToLinkName.match(myMissingLink)) {              
        myMissingLinks.relink(myBackUpFile);
        }
    }
}

}} catch (e) {
        
}
alert("Done Relinking!");

 

 

 

Regards,

Mike

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 Beginner ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

@Mike Bro  Wow - this works 😄 Great , thank you sooo much!

 

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
Advisor ,
Jan 03, 2021 Jan 03, 2021

Copy link to clipboard

Copied

LATEST

Hello Creativehub2324 !

 

I"m glad to help!.......out of curiosity how long did it take to relink 500 images?

 

Regards,

Mike

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