Copy link to clipboard
Copied
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
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.status == LinkStatus.LINK_MISSING)
{
$.writeln("Missing: "+imgs.name+" lookign in "+searchfolder);
// Do we have a file?
imglist = findAnyFileDownThere(imgs.name, searchfolder);
$.writeln("Found "+imglist.length+" possible replacements.");
if (imglist.length == 1)
{
// Oh yeah
imgs.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 [];
}
Copy link to clipboard
Copied
This looks like an InDesign script.
In Illustrator you got to use document.placedItems and check the property placedItem.file to see if the linked file is available.
However your undefined issue regarding the loop could be a result of something else.. I'd see if you're targeting Illustrator in your ESTK properly.
Copy link to clipboard
Copied
What about the error "there is no file associated with this item" we gave when ask for placedItems.file.
I have a document with a lot of embedded files and another with missing links. I need to relink but the code I wrote doesn't loop thru all the placedItems because of that error.
Copy link to clipboard
Copied
embedded images don't have a liked file property. embedded images are no longer linked from anywhere because they are... embedded. If you know where you want to find the file, you can use your script to place the image, scale it to match the existing embedded image (if neccessary), set the position to match the embedded image, then delete the embedded image (and then if need be, you can embed the image you just placed.) wow, i just said the word "embedded" an awful lot...
hope this helps..
... embedded..
Copy link to clipboard
Copied
Continuing here: Re: Relink AI files in AI document
Copy link to clipboard
Copied
I Have found a workaround! Please share this in as many Adobe forums as possible.
If you need to relink multiple of the same linked file (instead of clicking relink, select file, repeat, relink, select file, repeat)
Do this trick:
Move the current image file that is linked in the document - to a different destination (different folder, desktop, etc.)
When you go back to illustrator it will tell you that the file is missing and will tell you "Some files are missing or modified in the Links Panel. Would you like to update them now?"
Click YES
The next window will pop up saying "Could not find linked file..."
BE SURE TO CLICK THE – APPLY TO ALL BOX
Replace that linked file with your new linked file and.. Abracadabra.
Notes: As long as the images are the same DPI and Size you will be okay.
Copy link to clipboard
Copied
Indeed, this workaround is fine if you want to replace all linked images with the same linked image.. But as you pointed out, any variations will cause problems.. And i also can't think of very many scenarios in which you'd have tons of identical linked images in the same document..