Skip to main content
hayleys69485488
Participating Frequently
February 20, 2024
Beantwortet

Links Script - Search Folder for Missing Links and Copy to Links Folder

  • February 20, 2024
  • 4 Antworten
  • 1959 Ansichten

Hello!

I've already packaged my InDesign file and all links are in a links folder. I work on a server, and others sometimes need to work in the same file. There are lots of changes ongoing through the process of creating the publication. Result: I have some few links now linked to other folders. I would prefer not to NEWLY package the entire job just to collect up the 10 links scattered around.

 

I can "Relink to Folder" and the missing links show up just fine. BUT, I WANT all the links in the LINKS FOLDER ONLY 🙂 Not linked elsewhere. 

 

The names of the links are long strings of numbers, so very hard to find in the image dump where they currently are. It would take a lot of time to manually locate each one and copy it into my links folder.

 

Does anyone know of a script that will allow InDesign to search a folder for the missing links only, then copy and paste them to my existing links folder? This would be so I don't have to re-package the entire file?

 

Thanks! 

Beste Antwort von davidt12412601

@hayleys69485488 I'm not sure I understand. That function will first copy any files that are linked from elsewhere and paste them into your preferred links folder, then relink to the file in its new location. That gives you essentially the same result as packaging the file, as far as the links are concerned. Do you need to have a record of which files were moved, so you can do something else with the affected pages?

4 Antworten

Mike Witherell
Community Expert
Community Expert
February 22, 2024

"others sometimes need to work in the same file"

Part of what should be considered moving forward is a human-level solution. Where to save files and how to name them should be trained into each human.

Mike Witherell
hayleys69485488
Participating Frequently
February 23, 2024

Very good point. This was taken up with each involved and some rules agreed upon.

danaken3
Participating Frequently
February 22, 2024

I'm sure there is a better way to write this script, but it seems to get the job done. It prompts you to select the folder to search (note it will not search within any subfolders), and then select the folder you want to save to (e.g. the links folder). Let me know if it's not working as expected!

 

app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){
var myLinks = app.activeDocument.links;
var linkName;
var origFolder = Folder.selectDialog("Select folder to search");
var origFile;
var fileCount = 0;
var errorCount = 0;
var targetFolder = Folder.selectDialog("Select folder to save to");

for (i=0; i<myLinks.length; i++) {
    if (myLinks[i].status == LinkStatus.LINK_MISSING) {
        linkName = myLinks[i].name;
        try {
            origFile = origFolder.getFiles(linkName)[0];
            origFile.copy(targetFolder + "//" + linkName);
            fileCount++;
        }
        catch(err){
            errorCount++;
        }
    } 
}

alert("Files copied: " + fileCount + "\rErrors: " + errorCount);
}

 

Edit: Oops, I realized after rereading your post that your links probably aren't true "missing" links after all, and @davidt12412601's solution is probably what you're looking for!

 

hayleys69485488
Participating Frequently
February 23, 2024

This worked! I ran your script, it searched a folder I picked for missing links, and the relinked them and at the same time, it moved those links to my links folder. Very nice. Thank you!!! 

davidt12412601
Inspiring
February 21, 2024

I believe the "Copy Link(s) To" function under the Utilities submenu of the Links panel menu will do what you want. You can select all links in the links panel, then run "Copy Link(s) To" and choose your desired links folder. All links that are not already in that folder will be copied there. Links that are already in that folder will not be duplicated. And the references in the document will be updated to point to the new location.

hayleys69485488
Participating Frequently
February 22, 2024

Thanks so much! This would work, except I have so many links, and once they re-link, I can no longer find which ones are the ones that relinked. And their names are long strings of random numbers. So, not quite workable in this scenario. But I appreciate it and it's a good tool to have! I only just found out about this the other day...

davidt12412601
Inspiring
February 22, 2024

@hayleys69485488 I'm not sure I understand. That function will first copy any files that are linked from elsewhere and paste them into your preferred links folder, then relink to the file in its new location. That gives you essentially the same result as packaging the file, as far as the links are concerned. Do you need to have a record of which files were moved, so you can do something else with the affected pages?

grafik-kl
Inspiring
February 21, 2024

Hi,

there is a script named "Relink2NewPath" wich upgrade all links to a choosen folder. If the link is missing in the new folder, it keep the original link.

'Cause I'm not the creator of the script I don't post it here.

Maybe the function "Relink to new folder" (Links-window, flyout menue) will do the job too.

 

Jens

hayleys69485488
Participating Frequently
February 22, 2024

Hi grafik-kl, What do you mean when you say "upgrade" to a chosen folder? Do you mean copy?  

grafik-kl
Inspiring
February 22, 2024

Hi,

if you have one folder wich contains all your links, the script update all links to this new folder. The script does not copy any data, it just change the link-destinations.
Sorry for beeing so inaccurate, my english is al little bit rusty. 😉