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?
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();
}
...
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
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?
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
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....
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.
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.
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.
Copy link to clipboard
Copied
5. Go to Window > Utilities > Scripts and double click the script (if you have installed correctly).
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
Copy link to clipboard
Copied
@Mike Bro Wow - this works 😄 Great , thank you sooo much!
Copy link to clipboard
Copied
Hello Creativehub2324 !
I"m glad to help!.......out of curiosity how long did it take to relink 500 images?
Regards,
Mike