Hi, am wondering if it's possible to relink files in batch , my gut is saying no as all scripts ive found for relinking files references internal functions such as "app.documents". Aim is to update lots of broken links in a company fileshare (some files are 300+ links). Are there any other options?
Files are hosted on a windows server, but published as an apple fileshare using some software. This works fine, but I had to rename a folder and its broken lots of filelinks as a result.
I want to essentially find and replace a broken link path for all .ai files in the directory and all subdirectories with the new amended path.
The loop in red is giving me an "undefined is not an object" error. I'm guessing app.documents.length is undefined. I presume this should be where an input box appears when run from the scripts menu in the application. What am I missing?
Is there a way to relink files via script outside of illustrator? if there are xml files I can find and replace manually, this would be easier for me!
Any suggestions welcome!
The script is below:
var i, j, searchfolder;
for (j=0; j<app.documents.length; j++) {
doc = app.documents[j];
imgs = doc.links;
path = "afp://COMPANY-FP01 IP._afpovertcp._tcp.local/IllustratorScriptTest/"; //
searchfolder = new Folder(path);
for (i=0; i<imgs.length; i++)
{
// Missing?
$.writeln("Image "+i);
if (imgs[i].status == LinkStatus.LINK_MISSING)
{
$.writeln("Missing: "+imgs[i].name+" lookign in "+searchfolder);
// Do we have a file?
imglist = findAnyFileDownThere(imgs[i].name, searchfolder);
$.writeln("Found "+imglist.length+" possible replacements.");
if (imglist.length == 1)
{
// Oh yeah
imgs[i].relink(imglist[0]);
$.writeln("Relinked to "+imglist[0]);
}
}
}
}
function findAnyFileDownThere (filename, path)
{
var result, folderList, fl;
result = Folder(path).getFiles (filename+".*");
if (result.length > 0)
return result;
folderList = Folder(path).getFiles(function(item) { return item instanceof Folder && !item.hidden; });
for (fl=0; fl<folderList.length; fl++)
{
$.writeln("Looking in: "+path+"/"+folderList[fl].name);
result = findAnyFileDownThere (filename, path+"/"+folderList[fl].name);
if (result.length > 0)
return result;
}
return [];
}