Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to find missing links ans save in txt-doc?

Community Beginner ,
Oct 10, 2017 Oct 10, 2017

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

TOPICS
Scripting
4.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Oct 10, 2017 Oct 10, 2017

Ah sorry, the variable is called source_doc not doc. My mistake...

Instead use

source_doc.fullName

Translate
Guide ,
Oct 10, 2017 Oct 10, 2017

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;

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2017 Oct 10, 2017

tpk1982

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 10, 2017 Oct 10, 2017

Try replacing this line:

myarray.push( myimages.name)

With this line:

myarray.push( "Missing link: " + myimages.name + " in: " + doc.fullName );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2017 Oct 10, 2017

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 10, 2017 Oct 10, 2017

Ah sorry, the variable is called source_doc not doc. My mistake...

Instead use

source_doc.fullName

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2017 Oct 10, 2017

jakec88782761

Works like a charm.

Thanks a lot!

Best regards, Fredrik

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 12, 2017 Oct 12, 2017

jakec88782761

tpk1982

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 12, 2017 Oct 12, 2017

change line 21 to

app.activeDocument.close (SaveOptions.no)

in the provided script

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 12, 2017 Oct 12, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 13, 2017 Oct 13, 2017

And one more wish...:)

Is it possible to also get the full image path, to the missing link, in the report?

Best regards, Fredrik

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 13, 2017 Oct 13, 2017

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,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 13, 2017 Oct 13, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 13, 2017 Oct 13, 2017

The same line we changed before:

myarray.push( "Missing link: " + myimages.name + " Missing link path:" + myimages.filePath + " in: " + source_doc.fullName );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 13, 2017 Oct 13, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 28, 2018 Mar 28, 2018
LATEST

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.

Screen Shot 2018-03-29 at 00.04.39.png

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; 

 

    } 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 10, 2017 Oct 10, 2017

Hi,

Hope its helps!!

Re: need to relink missing links to files with extensions

Thanks,

Prabu G

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines