I am trying to get the name of a placed Item in Illustrator.
this is a hardcoded placed item, in case i have one selected on my artboard
var myItem = app.activeDocument.selection[0];
Normally I would get the name of the file like so:
myItem.file.name
But I want to get the name of a placed Item where the link (filepath) is broken.
Even if the link is broken, illustrator can still read the name of it, as you can see in the placed items window:
So how can I access that name?
For your reference XMPString will help you, this jsx snippet will find ALL filepaths of broken links, not a SELECTED item.
#target "Illustrator"
var doc = app.activeDocument;
$.writeln(doc.name);
var x = new XML(doc.XMPString);
var m = x.xpath('//stRef:filePath');
if (m !== '') {
for (var i=0, len=m.length(); i < len ; i++) {
var link_path = m[i];
if ( File(link_path).exists === false ) {
$.writeln(File(link_path).fsName);
}
};
}