be the change you want to see in the world
Posts tagged batch replace indesign
Replace selected image with another in Indesign
0544 days
Ever needed to change a bunch of picture from one document with another in Indesign? This script does just that …
function indexOf(array, elem) {
for(j= 0; j < array.length; j++) {
if(array[j] ==elem) return true;
}
return false;
}
var rFile;
if(app.documents.length > 0){
var myDoc = app.activeDocument;
var docLinks = myDoc.links;
var myDialog = app.dialogs.add({name:"Parameters:", canCancel:true});
with(myDialog){
with(dialogColumns.add( {})){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Replace image:"});
}
with(dialogColumns.add()){
var mDrop = dropdowns.add({ stringList:GetLinks(docLinks), selectedIndex: 0});
}
}
}
}
if(myDialog.show() == true ) {
rFile = File.openDialog ("Replacement file:");
} else {
myDialog.destroy();
exit();
}
} else {
alert("There is no opened document.");
}
function GetLinks(lks) {
var lA = new Array();
var lAi = 0 ;
for(i=0; i < lks.length; i++){
if(indexOf(lA, lks[i].name) == false) { lA[lAi] = lks[i].name; lAi++; }
}
return lA;
}
var imgName = myDoc.links.item(mDrop.stringList[mDrop.selectedIndex]).name;
var vLinks = myDoc.links;
var o = 0;
for(i=vLinks.length-1; i >= 0; i--){
if(vLinks[i].name == imgName){
vLinks[i].relink(rFile);
}
}
for(i=vLinks.length-1; i >= 0; --i){
if(vLinks[i].status == LinkStatus.LINK_OUT_OF_DATE) vLinks[i].update();
}
