Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Check out this script. It opens each InDesign document in the selected folder, updates all outdated links, saves and closes it.
Kasyan
Copy link to clipboard
Copied
Though it doesn't work. Thank you all the same.
Copy link to clipboard
Copied
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();
}
}
}
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thank you all very much. You guys are so warm-hearted to help. Next time, I will tell as more details as I can.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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();
}
}
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks so much. I already got what I want above.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now