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

Batch update links script?

Explorer ,
Jun 30, 2010 Jun 30, 2010

Does anyone have a script that will auto update the links in several InDesign documents? I have 121 InDesign documents that each have two updated .ai files. When I open they ask if I want to update. I need a script that tells each one yes to update and save.

I would also like to export a pdf of each file. Being able to chose my preset and overwrite the existing pdf. Batch process of course.

Thanks!

TOPICS
Scripting
10.6K
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
Jul 01, 2010 Jul 01, 2010

Please see the below script, which will update all links and it will generate ps file using your printpreset. Once the ps is generated you can drag into acrodistiller.

var printPreset;
var printPresetPath="D:\\Books\\Preset.prst";
var inputDirectory="D:\\IndFiles";
var inddFiles=new Array();

inddFiles=Folder(inputDirectory).getFiles();

//Suppress all dialogs
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

for(var indCount=0; indCount < inddFiles.length; indCount++)
{
    if (String(inddFiles[indCount]).match(/\.indd$/i))
    {
        var aDoc=app.open(File(inddFiles[indCount]), true);
       
        //Links update
        aDoc.links.everyItem().update();
       
        //Removing existing printpresets
        for(var pP=0; pP < app.printerPresets.length; pP++)
        {
            var myprintPreset = app.printerPresets.item(pP);
            if (String(app.printerPresets.item(pP).name) != '[Default]')
            {
                myprintPreset.remove();
            }
        }
       
        //Adding our print preset
        printPreset=File(printPresetPath);
        app.importFile(1918071916, printPreset);
        myprintPreset=app.printerPresets.lastItem();
       
        //Generating PS in the application path
        myprintPreset.printFile = File(aDoc.filePath+'/'+String(aDoc.name).substr(0, (String(aDoc.name).length-5))+'.ps');
        aDoc.print(false, myprintPreset);
   
        //Save and close
        aDoc.close(2036691744);
    }
}

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

Arivu....

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 ,
Nov 25, 2010 Nov 25, 2010

I wanna know is there possible to have a script  that can batch update links of open files. Just update the links. Though, you have written some code here. But I don't how to use it. I have been searched it for a very long time.

And I want to learn something about indesign script. But I don't know where to start. Only indesign script. Could you show me what to do?

Thank you in advance.

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 Expert ,
Nov 26, 2010 Nov 26, 2010

How to install and use scripts into your Indesign: http://indesignsecrets.com/how-to-install-scripts-in-indesign.php

General starting info and guides: http://www.adobe.com/products/indesign/scripting/ -- click the Scripting Resources tab, then download the Introduction, Tutorial, and In-Depth guide for your version of InDesign.

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 ,
Nov 26, 2010 Nov 26, 2010

Maybe I didn't make myself clear. My poor English. I do know how to use scripts in indesign. What I mean is when I click the script above, nothing happens. I did what you guided me before, three pdfs, and I do not know what to do. You know what to do about indesign scripting and where to start, right?

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
Valorous Hero ,
Nov 29, 2010 Nov 29, 2010

Check out this script. It opens each InDesign document in the selected folder, updates all outdated links, saves and closes it.

Kasyan

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 ,
Nov 29, 2010 Nov 29, 2010

Though it doesn't work. Thank you all the same.

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
Valorous Hero ,
Nov 30, 2010 Nov 30, 2010

I retested the script and it works for me (I am on CS3 for Windows). You want to update all modified links in all open documents, don't you? Did I get you right?

Kasyan

if (app.documents.length == 0) {
     alert("Please open a document and try again.");
     exit();
}

var docs = app.documents;

for (var i = 0; i < docs.length; i++) {
     UpdateAllOutdatedLinks(docs);
}

alert("Finished");

function UpdateAllOutdatedLinks(doc) {
     for (var d = doc.links.length-1; d >= 0; d--) {
          var link = doc.links;
          if (link.status == LinkStatus.linkOutOfDate) {
               link.update();
          }
     }
}

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 ,
Nov 30, 2010 Nov 30, 2010

Yes. Yes. That's what I mean. You are great. Thank you so much. It works well in CS2 and CS4 also. BTW, I want to learn how to write script. Should I start from a Java book? Could you kindly recommend?

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
Valorous Hero ,
Nov 30, 2010 Nov 30, 2010

BTW, I want to learn how to write script. Should I start from a Java book? Could you kindly recommend?

Here's a list of resources I recommend to first-time scripters, and here's a list of links where you can find information on more advanced topics. I also recommend you strongly to download and use Jongware's InDesign JavaScript Reference Guide -- it's much better than the built-in Object Model Viewer. And don't confuse Java with JavaScript --  these are totally different programing languages -- the latter is used for writing scripts for InDesign and some other adobe applications.

Kasyan

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 ,
Dec 01, 2010 Dec 01, 2010

Thank you all very much. You guys are so warm-hearted to help. Next time, I will tell as more details as I can.

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
New Here ,
Dec 04, 2021 Dec 04, 2021

I am new to using scripts in InDesign and am wanting to batch update links in InDesign files. Will the script work for InDesign CC? Thank you!

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 Expert ,
Dec 04, 2021 Dec 04, 2021

Yes, in most probability it will work. What's stopping you from giving it a try, if it fails then share the problem you face and someone will surely help you out. Also, please don't open up such old threads, it's better to write your own post, that has better chances of getting responses.

-Manan

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 Expert ,
Dec 05, 2021 Dec 05, 2021

 

 

Hi @sanjayb75202732 ,

This thread is from 2010 and JS code in old posts can get corrupted—the loop variables get dropped. I think @Kasyan Servetsky ’s script shold be this:

 

if (app.documents.length == 0) {
     alert("Please open a document and try again.");
     exit();
}

var docs = app.documents;

for (var i = 0; i < docs.length; i++) {
     UpdateAllOutdatedLinks(docs[i]);
}

alert("Finished");

function UpdateAllOutdatedLinks(doc) {
     for (var d = doc.links.length-1; d >= 0; d--) {
          var link = doc.links[d];
          if (link.status == LinkStatus.linkOutOfDate) {
               link.update();
          }
     }
}

 

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
LEGEND ,
Nov 30, 2010 Nov 30, 2010

Though it doesn't work. Thank you all the same.

"Batch update links

Script for InDesign CS3/4, version 1.0."

What version of InDesign do you have ?

robin

www.adobescripts.co.uk

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 ,
Nov 30, 2010 Nov 30, 2010

Thanks so much. I already got what I want above.

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
LEGEND ,
Nov 30, 2010 Nov 30, 2010

Thanks so much. I already got what I want above.

Fine, but please - next time - tell us what version of InDesign you have.

robin

www.adobescripts.co.uk

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
Participant ,
Nov 15, 2023 Nov 15, 2023
LATEST

@rob day's solution (link) works perfectly. Thanks @rob day 

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