Copy link to clipboard
Copied
I am looking for a script that will rename the layer name <group> with the linked file name it was embedded from . I will try my best to explain with screenshots.
The Process:
I bring in files and place them on an artboard. Each layer is given the name <linked file>.
Once I embed the links the layer name is changed to <group>
I would like to replace the <group> name with the linked file name it was originally connected with.
I think this is possible with scripting, but I'm not sure.
Any help is greatly appreciated.
Thanks!
Copy link to clipboard
Copied
Try this snippet out, it may be what you are looking for!
#target illustrator
function test () {
var doc = app.activeDocument;
var thisPlacedItem;
var newGroup;
var thisPlacedFile;
var thisName;
for (var i = doc.placedItems.length - 1; i > -1; i--) {
thisPlacedItem = doc.placedItems[i];
thisPlacedFile = thisPlacedItem.file;
thisName = decodeURI(thisPlacedFile.name);
newGroup = thisPlacedItem.parent.groupItems.add();
newGroup.move(thisPlacedItem, ElementPlacement.PLACEBEFORE);
newGroup.name = thisName;
thisPlacedItem.move(newGroup, ElementPlacement.INSIDE);
thisPlacedItem.embed();
}
};
test();
Copy link to clipboard
Copied
Worked like a dream!
I mean this when I say it... You are my hero Silly-V!
Copy link to clipboard
Copied