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

Script that renames <group> layer name to the name of the linked file it was embedded from

Explorer ,
Jan 11, 2021 Jan 11, 2021

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:

 

Screen Shot 2021-01-11 at 11.23.10 AM.png

I bring in files and place them on an artboard.  Each layer is given the name <linked file>.

 

Screen Shot 2021-01-11 at 11.23.35 AM.png

Once I embed the links the layer name is changed to <group>

Screen Shot 2021-01-11 at 11.24.58 AM.png

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!

 

 

 

TOPICS
Scripting

Views

488

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

correct answers 1 Correct answer

Valorous Hero , Jan 11, 2021 Jan 11, 2021

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

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jan 11, 2021 Jan 11, 2021

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();

 

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
Explorer ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

Worked like a dream!

 

I mean this when I say it...  You are my hero Silly-V!

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
New Here ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

LATEST

Hey @Silly-V

 

would this work in photoshop?

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