Copy link to clipboard
Copied
Hi,
I producing manuals that contain a spare parts list with a lot of drawings.
The drawing files are in pdf format and are automatically generated from AutoCAD.
These pdf drawings I place in my InDesign file.
Unfortunately these files change names with a suffix when they are updated.
The namning of these files are NNNNNN-A for revision A, NNNNNN-B for revision B and so on.
So when I open my InDesing files there aren't any warnings that some files are updated because InDesign of course checks the links and looks for NNNNNN-A and sees that nothing has happened to that file.
But AutoCAD has generated a new updated file with a new suffix"B": NNNNNN-B.
So I was wondering if there is a way for InDesign to see that a file has a new suffix "B" and recognize it as the updated revision of the file with the "A" suffix and let me know that there is an updated file?
Regards,
Magnus
Hi Magnus,
The solve is posted here, all credit goes to Mike Bro. I only changed the regex to suit your ask and added the LINK_MISSING loop.
https://community.adobe.com/t5/indesign-discussions/indesign-script-to-relink-the-images-to-match-with-partial-names/m-p/12086790
The caveat is that prior to running it. you need to move the outdated files out of the link folder so that their Link Status are shown as MISSING. This basically look for a the NNNNNN- pattern and relink to any file that matches it,
Copy link to clipboard
Copied
Hi Magnus,
The solve is posted here, all credit goes to Mike Bro. I only changed the regex to suit your ask and added the LINK_MISSING loop.
https://community.adobe.com/t5/indesign-discussions/indesign-script-to-relink-the-images-to-match-wi...
The caveat is that prior to running it. you need to move the outdated files out of the link folder so that their Link Status are shown as MISSING. This basically look for a the NNNNNN- pattern and relink to any file that matches it, ignoring the suffix (A, B, C). You can modify the number of prefix letters and/or use 1, 2, 3 instead.
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++){
for (var i = 0; i < doc.links.length; i++){
if (doc.links[i].status == LinkStatus.LINK_MISSING){
if (doc.links[i].name.match(/^(\w{6}\-)\w\.[a-z]+$/gi,)){
var myLinks = doc.links[i];
var myLink = doc.links[i].name.replace(/^(\w{6}\-)\w\.[a-z]+$/gi, '$1');
for (var f = 0; f <myFilesToLink.length; f++) {
if (myFilesToLink[f].name.match(/^(\w{6}\-)\w\.[a-z]+$/gi,)){
var myRevisedFile = myFilesToLink[f];
var myFilesToLinkName = myFilesToLink[f].name.replace(/^(\w{6}\-)\w\.[a-z]+$/gi, '$1');
if (myFilesToLinkName.match(myLink)) {
myLinks.relink(myRevisedFile);
}
}
}
}
}
}
}
Copy link to clipboard
Copied
Sorry @ck_ny for waiting over a year with a reply.
I tried it at once and was so happy it worked so I guess I forgot to log in and say thanks.
So......thank you!