• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Relink AI files in AI document

Enthusiast ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

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!

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

I'm trying the name or file.name. But none of my plans are working.

Any idea?

In some cases I'll have two AI files to relink...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

And, just explaining why I'm trying with the name:

I'll have a lot of documents to process. And some of them have two AI files linked.

I need to know which AI must be replaced (relinked) with which new AI. Am I clear?

For example: background arts must be relinked by background new arts... and the name is what define this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

Found an exciting solution on stackOverflow.

var doc = app.activeDocument;

var x = new XML(doc.XMPString);

var m = x.xpath('//stRef:filePath');

var myMissingLinks = [];

var myLinks = [];

if (m !== '') {

    for (var i=0, len=m.length(); i<len ; i++) {

        var link_path = m;

        if (File(link_path).exists === false) {

            myMissingLinks.push(File(link_path).fsName);

            }

        else {

            myLinks.push(File(link_path).fsName);

            }

        }

    }

javascript - ExtendScript Illustrator Placed Item Name - Stack Overflow

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

If there are multiple placed items in XMP, how do you know which is the target file?

I solved this problem like this.

1. Bind a placed item to a link variable

2. Export variable library

3. Analyze the XML

https://sttk3.com/blog/tips/illustrator/relink-spotlight.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

LATEST

I saw this behavior some time ago, but I think I began to believe it would work on getting embedded item data (which is sometimes visible in the Links panel ?) - however it's a good confirmation that this method is viable for placed items whose links have been lost.

Re: Want to print the Links in my Artboard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines