Script to update all links in InDesign Book file

Community Beginner ,
Nov 02, 2017 Nov 02, 2017

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

4.1K

Likes

Translate

Translate

Report

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 2 Correct answers

Advocate , Nov 03, 2017 Nov 03, 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]);

        }

    }

Likes

Translate

Translate
Advocate , Nov 09, 2017 Nov 09, 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

...

Likes

Translate

Translate
Guru ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

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

— Kas

Likes

Translate

Translate

Report

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 ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

Thanks Kas, I’ll give it a try.

Likes

Translate

Translate

Report

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
Explorer ,
Jan 02, 2022 Jan 02, 2022

Copy link to clipboard

Copied

LATEST

The links were broken, but I've searched and found the scripts in your wonderful repository at
http://kasyan.ho.ua/scripts_by_categories.html

 

After almost 12 years of Indesign, only less than a month ago I started to use scripts.
I'm amazed by the team work here in the support community and in the other forums around. 

 

Thank you so much!

Likes

Translate

Translate

Report

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
Advocate ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

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]);

        }

    }

Likes

Translate

Translate

Report

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
Advocate ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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 ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

Suni,

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

Likes

Translate

Translate

Report

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
Advocate ,
Nov 09, 2017 Nov 09, 2017

Copy link to clipboard

Copied

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]);

                }

            }

        }

    }

Likes

Translate

Translate

Report

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