Skip to main content
Participating Frequently
November 2, 2017
Answered

Script to update all links in InDesign Book file

  • November 2, 2017
  • 4 replies
  • 7259 views

Hi!

I have a Book file with multiple InDesing files. They all have some picture files placed as linked files. In case those images are modified, the links would need to be updated obviously. I know I can do it by opening the file and clicking "Update Links", but I don't want to open 57 files and click the button.

I do know how to use scripts, but I don't know how to make them. Can anyone help?

Actually, this should be a feature in InDesign Book: update all linked files in selected book documents.

This topic has been closed for replies.
Correct answer Sunil Yadav

Try this...

var add = new Folder("C:/myInddFolder/");

var myFileList = add.getFiles();

for (var i = 0; i < myFileList.length; i++) {

    var myFile = myFileList;

    if (myFile instanceof File && myFile.name.match(/\.indd$/i)) {

        //~             Open indesign file one by one and update

        var myDoc = app.open(new File(add+"/"+myFiles.name));

        var linkImg = myDoc.links;

        var filePath = "E:/SunilY/Files/Images";

        for(var i = 0; i < linkImg.length; i++){

            if(linkImg.status == LinkStatus.LINK_MISSING){

                var imgFolder = Folder(filePath).getFiles (linkImg.name+".*");

                linkImg.relink(imgFolder[0]);

                }

            }

        }

    }

4 replies

New Participant
April 1, 2023

var myDoc = app.documents[0];
var linkImg =myDoc.links;
for(var i = 0; i < linkImg.length; i++){
linkImg[i].update();
}

Sunil Yadav
Brainiac
November 6, 2017

In case Images are modified but no their names, then links will get automatically updated but if you change their location and names are same then you can use above script by defining its path...

Thanks

SunilY

therodeeAuthor
Participating Frequently
November 6, 2017

Suni,

yes they are automatically updated, if I open the documents.

Sunil Yadav
Sunil YadavCorrect answer
Brainiac
November 9, 2017

Try this...

var add = new Folder("C:/myInddFolder/");

var myFileList = add.getFiles();

for (var i = 0; i < myFileList.length; i++) {

    var myFile = myFileList;

    if (myFile instanceof File && myFile.name.match(/\.indd$/i)) {

        //~             Open indesign file one by one and update

        var myDoc = app.open(new File(add+"/"+myFiles.name));

        var linkImg = myDoc.links;

        var filePath = "E:/SunilY/Files/Images";

        for(var i = 0; i < linkImg.length; i++){

            if(linkImg.status == LinkStatus.LINK_MISSING){

                var imgFolder = Folder(filePath).getFiles (linkImg.name+".*");

                linkImg.relink(imgFolder[0]);

                }

            }

        }

    }

Sunil Yadav
Brainiac
November 3, 2017

Hi therodee,

          You can relink all graphics by finding their status.

var myDoc = app.documents[0];

var linkImg =myDoc.links;

var filePath = "E:/SunilY/Files/Images";

for(var i = 0; i < linkImg.length; i++){

    if(linkImg.status == LinkStatus.LINK_MISSING){

        var imgFolder = Folder(filePath).getFiles (linkImg.name+".*");

        linkImg.relink(imgFolder[0]);

        }

    }

Kasyan Servetsky
Brainiac
November 3, 2017

Here you can find the Update modified links script which should be used with the Batch processor script.

— Kas

therodeeAuthor
Participating Frequently
November 6, 2017

Thanks Kas, I’ll give it a try.