Edit code for change drive letters in paths for links, to also work with Fonts that have been moved.
i have following code looks through links , changes of drive letters new locations exist. if stays in same folder structure, moves new drive e: , indesign can not longer find it, can run code , have fix them all.
well want same fonts have moved.
thank in advance , help!
if (app.documents.length == 0) { err("no open document. please open document , try again.", true); } if (file.fs != "windows") { err("this script windows only."); } var mydoc = app.activedocument; var mylinks = mydoc.links; var mycounter = 0; if (mylinks.length == 0) { err("this document doesn't contain links.", true); } var mysettings = createdialog(); (i = mylinks.length-1; >= 0 ; i--) { var mylink = mylinks[i]; if ( mylink.status == linkstatus.link_missing || (mylink.status != linkstatus.link_missing && mysettings[2] == false) ) { var myoldpath = mylink.filepath; var mynewpath = myoldpath.replace(mysettings[0] + ":\\", mysettings[1] + ":\\"); var mynewfile = new file(mynewpath); if (mynewfile.exists) { mylink.relink(mynewfile); try { mylink.update(); } catch(e) {} mycounter++; } } } if (mycounter == 1) { alert("one file has been relinked.", "finished"); } else if (mycounter > 1) { alert(mycounter + " files have been relinked.", "finished"); } else { alert("nothing has been relinked.", "finished"); } function err(e, icon){ alert(e, "change drive letter in path", icon); exit(); } function createdialog() { var mydrives = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; var mydialog = new window("dialog", "change drive letter in path"); var mypanel = mydialog.add("panel", undefined, ""); mypanel.orientation = "column"; mypanel.alignchildren = "left"; var mygroup = mypanel.add("group"); mygroup.orientation = "row"; var mysttext1 = mygroup.add("statictext", undefined, "change "); var mydropdownlist1 = mygroup.add("dropdownlist", undefined, mydrives); if (app.extractlabel("kas_updatepathnamesafterdriveletterchange_3.0_ddl1") != "") { mydropdownlist1.selection = mydropdownlist1.items[app.extractlabel("kas_updatepathnamesafterdriveletterchange_3.0_ddl1")]; } else { mydropdownlist1.selection = mydropdownlist1.items[2]; } var mysttext2 = mygroup.add("statictext", undefined, " "); var mydropdownlist2 = mygroup.add("dropdownlist", undefined, mydrives); if (app.extractlabel("kas_updatepathnamesafterdriveletterchange_3.0_ddl2") != "") { mydropdownlist2.selection = mydropdownlist2.items[app.extractlabel("kas_updatepathnamesafterdriveletterchange_3.0_ddl2")]; } else { mydropdownlist2.selection = mydropdownlist2.items[3]; } var mycheckbox = mypanel.add("checkbox", undefined, "relink missing links"); if (app.extractlabel("kas_updatepathnamesafterdriveletterchange_3.0_checkbox") != "") { mycheckbox.value = eval(app.extractlabel("kas_updatepathnamesafterdriveletterchange_3.0_checkbox")); } else { mycheckbox.value = true; } var mybuttonsgrp = mydialog.add("group"); var myokbtn = mybuttonsgrp.add("button", undefined, "ok", {name:"ok"}); var mycancelbtn = mybuttonsgrp.add("button", undefined, "cancel", {name:"cancel"}); myokbtn.onclick = function() { if (mydropdownlist1.selection.index == mydropdownlist2.selection.index) { alert("both drive letters should not same.", "change drive letter in path"); } else { mydialog.close(1); } } var mydialogresult = mydialog.show(); if (mydialogresult == 1) { app.insertlabel("kas_updatepathnamesafterdriveletterchange_3.0_ddl1", mydropdownlist1.selection + ""); app.insertlabel("kas_updatepathnamesafterdriveletterchange_3.0_ddl2", mydropdownlist2.selection + ""); app.insertlabel("kas_updatepathnamesafterdriveletterchange_3.0_checkbox", mycheckbox.value + ""); return [ mydropdownlist1.selection.text, mydropdownlist2.selection.text, mycheckbox.value ]; } else { exit(); } }
or @ least point me documentation on referencing font links collection?
i find hard find schema/documentation on indesign framework.
More discussions in InDesign Scripting
adobe
Comments
Post a Comment