Skip to main content
lfcorullon13651490
Legend
February 18, 2019
Question

Relink AI files in AI document

  • February 18, 2019
  • 1 reply
  • 1840 views

Hello, there.

I'm trying to figure out how to relink AI files in my AI document even if this linked AI file is missing.

But, if it's missing, the ESTK gives me an error saying "there is no file associated with this item".

How the hell can I get even the missing linked (placed) files?

As my document has a lot of embedded items, I really don't know if the error is because of that embedded or the broken links.

Any help will be appreciated!

This topic has been closed for replies.

1 reply

Disposition_Dev
Legend
February 18, 2019

i replied to your comment in the other post, but to keep related things together, i'll post the answer here as well in case it helps someone else as well.

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..

lfcorullon13651490
Legend
February 18, 2019

Ok. They don't have the property, but if I loop into placedItems, those embedded ones are in the loop?

If not, they're not my problem.

I just need to relink AI files, so, I need to have the name of the placedItem to  check if it's an AI file or not. Am I clear?

So, I'm trying something like:

for (var i=0; i<app.activeDocument.placedItems.length; i++) {

    if (app.activeDocument.placedItems.file.name.match(/\.ai$/i)) {

        alert(app.activeDocument.placedItems.name);

        }

    }

and a lot of variations like:

app.activeDocument.placedItems.file.name.match(/\.ai$/i)

app.activeDocument.placedItems.file.match(/\.ai$/i)

app.activeDocument.placedItems.name.match(/\.ai$/i)

None of them works, just because the code stops with the mentioned error.

Thank you so much for your help!

Disposition_Dev
Legend
February 18, 2019

an embedded image won't have a name unless you have explicitly given it one (whether from the script or in the GUI). name is not a default property.. (or at least the default value of name is just 'undefined').

Are you relying on the name to determine which file you need to link? because if that's the case you'll need to forumlate a new plan unfortunately.. =(