Copy link to clipboard
Copied
Hello Experts!
I wonder if there is an existing script, or one easy to make.
I would like to in batch (folders and subfolders) search for missing links in InDesign-documents, and get a list of the misssing links in an txt-file.
Thanks in advance!
Best regards, Fredrik
Ah sorry, the variable is called source_doc not doc. My mistake...
Instead use
source_doc.fullName
Copy link to clipboard
Copied
Hi..
try this..
mycheck()
function mycheck(){
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var csv = new File("~/Desktop"+"/Missing Image List.txt");
var log=[];
try{
myarray=[];
var root = Folder.selectDialog("Root folder");
var myfiles = [];
getsubfolderfiles(root);
for(var i =0;i<myfiles.length;i++)
{
var source_file = myfiles;
var source_doc = app.open(source_file);
myimages = source_doc.links;
for(var m =0;m<myimages.length;m++){
if(myimages
.status == LinkStatus.LINK_MISSING){ myarray.push( myimages
.name) }
}
app.activeDocument.close ();
}
myarray.sort();
found = [];
for(var i=0;i<myarray.length;i++)
{
if(myarray[i+1]!=myarray)
{
found.push(myarray);
}
}
log=log+("Used Link names (Repeated names eliminated):\n____________________________________________\n\n"+"Total number of links found: "+found.length+"\n\n");
log=log+(found.join("\n"));
if(csv.exists){csv.remove;}
csv.open("w");
csv.write(log);
csv.close();
alert("Report Saved in Desktop"+"\r"+"Click OK to see the report now")
csv.execute();
}
catch(er){}
function getsubfolderfiles(folder)
{
var filelist = folder.getFiles();
for(var i =0;i<filelist.length;i++)
{
if(filelist instanceof Folder)
{
getsubfolderfiles (filelist);
}
else if(filelist instanceof File)
{
if(filelist.name.indexOf(".indd") > -1){
myfiles.push(filelist);
}
}
}
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
}
Copy link to clipboard
Copied
Hi!
Excellent!
Is it possible to have the full path in the report, and to have the title of each document with an missing link in the report so that you find in what document the missing link is located?
Thanks in advance!
Best regards, Fredrik
Copy link to clipboard
Copied
Try replacing this line:
myarray.push( myimages
.name)
With this line:
myarray.push( "Missing link: " + myimages
.name + " in: " + doc.fullName );
Copy link to clipboard
Copied
jakec88782761 skrev
Try replacing this line:
myarray.push( myimages.name)
With this line:
myarray.push( "Missing link: " + myimages.name + " in: " + doc.fullName );
Thanks!
But when i add doc.fullName the script stops there, and it keeps the first document that is opened open. Do i miss something?
Copy link to clipboard
Copied
Ah sorry, the variable is called source_doc not doc. My mistake...
Instead use
source_doc.fullName
Copy link to clipboard
Copied
Copy link to clipboard
Copied
UPDATE, and another problem.
Hi!
If i run this on a InDesign CC2015, and opens up an CS6 document, the document gets converted, Indesign can't close the document, and the script stops. Any way to get around it?
Thanks in advance!
Best regards, Fredrik
Copy link to clipboard
Copied
change line 21 to
app.activeDocument.close (SaveOptions.no)
in the provided script
Copy link to clipboard
Copied
HI! tpk1982
Thanks for the advice.
It seems to work if there are no missing links in the document, but if there are som missing links it will stop with the open layout.
Best regards, Fredrik
Copy link to clipboard
Copied
And one more wish...:)
Is it possible to also get the full image path, to the missing link, in the report?
Best regards, Fredrik
Copy link to clipboard
Copied
Hi,
use .filepath and below code for your reference.
var doc = app.activeDocument;
var links = doc.links;
for(var i = 0; i < links.length; i++)
{
link = links;
if (link.status == LinkStatus.LINK_MISSING)
{
alert (link.filePath);
}
}
Adobe InDesign CS6 (8.0) Object Model JS: File
Thanks,
Prabu G
Copy link to clipboard
Copied
Ananth@desgin skrev
Hi,
use .filepath and below code for your reference.
var doc = app.activeDocument; var links = doc.links; for(var i = 0; i < links.length; i++) { link = links; if (link.status == LinkStatus.LINK_MISSING) { alert (link.filePath); } }
Adobe InDesign CS6 (8.0) Object Model JS: File
Thanks,
Prabu G
Thanks for you help!
I'm sorry but i cant get it to work and i'm really not sure where to put your code in script.
Any chance that you could paste in you lines in the script for me.
Best regards, the nOOb Fredrik
Copy link to clipboard
Copied
The same line we changed before:
myarray.push( "Missing link: " + myimages
.name + " Missing link path:" + myimages .filePath + " in: " + source_doc.fullName );
Copy link to clipboard
Copied
jakec88782761 skrev
The same line we changed before:
myarray.push( "Missing link: " + myimages.name + " Missing link path:" + myimages .filePath + " in: " + source_doc.fullName );
Works!
Thanks!
BR, Fredrik
Copy link to clipboard
Copied
I attempted to tweak this script to get a list of images held on an indd spread that are NOT linked to a specific folder — thus every other image should be listed.
But used the filePath property, and the “not equal”operator != to the string ":Da%20Dump:dPart_2_BACK_UP:Desktop_Clutter" (Macs requiring : delimiters versus / — per the indesign object model) with no desired results — the images from the folder path I’m attempting to exclude still show up along with every other image in the final list generated ?
Line 20 is where I attempt to set the excluded folder path — any help with this is greatly appreciated. Thanks.
Jongware’s site indesign object model.

Line 20 is the only area I made changes to.
// FROM: https://forums.adobe.com/message/9877344#9877344 ————————————————————————
mycheck()
function mycheck(){
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var csv = new File("~/Desktop"+"/Missing Image List.txt");
var log=[];
try{
myarray=[];
var root = Folder.selectDialog("Root folder");
var myfiles = [];
getsubfolderfiles(root);
for(var i =0;i<myfiles.length;i++)
{
var source_file = myfiles;
var source_doc = app.open(source_file);
myimages = source_doc.links;
for(var m =0;m<myimages.length;m++){
if(myimages
.filePath != ":Da%20Dump:dPart_2_BACK_UP:Desktop_Clutter"){ myarray.push( "Missing link: " + myimages
.name + " in: " + source_doc.fullName ); }
}
app.activeDocument.close ();
}
myarray.sort();
found = [];
for(var i=0;i<myarray.length;i++)
{
if(myarray[i+1]!=myarray)
{
found.push(myarray);
}
}
log=log+("Used Link names (Repeated names eliminated):\n____________________________________________\n\n"+"Total number of links found: "+found.length+"\n\n");
log=log+(found.join("\n"));
if(csv.exists){csv.remove;}
csv.open("w");
csv.write(log);
csv.close();
alert("Report Saved in Desktop"+"\r"+"Click OK to see the report now")
csv.execute();
}
catch(er){}
function getsubfolderfiles(folder)
{
var filelist = folder.getFiles();
for(var i =0;i<filelist.length;i++)
{
if(filelist instanceof Folder)
{
getsubfolderfiles (filelist);
}
else if(filelist instanceof File)
{
if(filelist.name.indexOf(".indd") > -1){
myfiles.push(filelist);
}
}
}
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
}
Copy link to clipboard
Copied
Hi,
Hope its helps!!
Re: need to relink missing links to files with extensions
Thanks,
Prabu G
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more