Current position:  Home > Default > Batch Retrieve Image links

Batch Retrieve Image links

Time:December 10
Advertisement
Hi,
I've found the File -> Package -> Report quite helpful for generating a detailed report for image links. However I am dealing with a few hundred files so the act of going into each one and generating a report individually is quite time consuming. I have been able to reduce the overall time by a) customing the hotkey for accessing the Package and b) memorizing the keystrokes required to complete each report however I can't help but think there has to be an easier way.
My assumption is that there would be a way to script such a simple action so that I could simply hit play and have the file generated, am I correct?
If not my second assumption is it would be easier to troll through the XML files and parse the links that way?
Thank-you very much in advance for any and all support in this matter.
Cheers,
Kud
Advertisement
OK, try this out:
var inFolder = Folder.selectDialog("Choose the folder that contains the InDesign documents.");
if(inFolder === null){
          exit();
var outFolder = Folder.selectDialog("Choose the folder to save the reports in.");
if(outFolder === null){
          exit();
var files = inFolder.getFiles("*.indd"),
          fileStrings = [],
          doc, i, l, link, j, k, reportFile;
app.scriptPreferences.userInteractionLevel=UserInteractionLevels.NEVER_INTERACT;
for(i = 0, l = files.length; i < l; i++) {
          doc = app.open(files[i], false);
          reportFile = File(outFolder + "/" + doc.name.replace(/\.indd$/,"") + ".csv");
          fileStrings = ["\"link\",\"status\",\"complete name\""];
          for(j = 0, k = doc.links.length; j < k; j++) {
                    link = doc.links[j];
                    fileStrings[fileStrings.length] = "\"" + link.name + "\",\"" + link.status.toString() + "\",\"" + link.filePath + "\"";
          doc.close(SaveOptions.NO);
          if(fileStrings.length > 1 && reportFile.open('w')){
                    reportFile.write(fileStrings.join("\r"));
                    reportFile.close();
app.scriptPreferences.userInteractionLevel=UserInteractionLevels.INTERACT_WITH_ALL;
So, this will ask you to choose the folder that contains the InDesign documents you want link reports on. It won't descend into subfolders. If your files aren't all in one folder, you can drag aliases/shortcuts into one folder and it should follow them. It will then ask you for a folder to save the report files in. It's set up to make one .csv for each document, and it doesn't produce them for documents that have no links.
Let me know if the file format I've chosen doesn't work for you, or if you'd rather have all of it in one document, or more fields, or whatever.
Tested on CS5 on the Mac.