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

Release to Layers but retain layer names

Explorer ,
Jul 14, 2011 Jul 14, 2011

Copy link to clipboard

Copied

I am unable to find a script that will do this. The default application functionality is really frustrating how it just slaps a generic "Layer 1", "Layer 2" layer name on the new layers. I would rather have the name of the sublayer become the name of the new layer. Has anyone seen a script anywhere that does this?

TOPICS
Scripting

Views

15.6K

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

Community Expert , Apr 21, 2016 Apr 21, 2016

you need to copy and paste the code into any text editor and save it as jsx

Installing scripts in the Scripts menu

To include a script in the Scripts menu (File > Scripts), save the script in the Scripts folder, located in the

/lllustrator CC/Presets folder in your lllustrator CC installation directory. The script’s filename, minus

the file extension, appears in the Scripts menu.

Scripts that you add to the Scripts folder while Illustrator is running do not appear in the Scripts menu until

the next ti

...

Votes

Translate

Translate
Adobe
Community Beginner ,
Feb 26, 2024 Feb 26, 2024

Copy link to clipboard

Copied

Hey Jass,

Thanks for the answer. 

It still doesnt work for me, I dont understand. I follow all the steps and the same error keeps coming up. Really annoying. Any further help would be super appreaciated.

Thanks

Gemma

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 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

Hi Gemma, what's the error you're getting?

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 Beginner ,
Feb 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

Hey Carlos,

I'm getting the same error than before, see attached.

I saved the text as plain text and tried .js and .jsx

 

Any help, really appreaciated.

Thanks

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 Beginner ,
Feb 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

Hey again,

 

Well I don't know what the different is between these files (see attached) but it works for "bg_beach.ai" but not for the rest.

At least I know that it works with some files! Exciting.

 

 

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 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

ok, then the script works. Make sure your layers are setup like the file that had no issues running the script on.

 

or follow the below steps

 

1. your layers should look like this

 

CarlosCanto_0-1709102678212.png

 

2. select Layer 1 then do Release to Layers (sequence)

 

CarlosCanto_1-1709102835486.png

 

3. keep Layer 1 selected then run the script, your layers should look like this

 

CarlosCanto_2-1709103229253.png

 

enjoy

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 Beginner ,
Feb 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

Might not be relevant but I was initially getting an error as I'd copied Carlos' text into Text Edit (I'm on a Mac) before saving out as a .jsx file.

Problem was, I'd left it as Rich text. Once I'd formatted it to plain text and resaved, bingo.

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 Beginner ,
Feb 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

Many, many years later, amazing, thanks Carlos!

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 ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

It's crazy that this is still an issue, but also, thanks from me, Carlos! And thanks, Simon, for mentioning the "rich text" issue; it helped me a lot. 🙂

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 ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

If anyone is out there still having the 1302 error, editing the code like this worked for me. It had to do with the type of layer inside my layers, if that makes sense. I just removed pageItems. Here's the edit:

var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

for (i=0; i<ilayer.layers.length; i++)

     {

          var sublayer = ilayer.layers[i];

          sublayer.name = sublayer[0].name;

     }

 

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 ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

Well it worked for some of my layers. I edited the code further so that it tries both types and if it doesn't work it just skips them. @CarlosCanto sorry to bother you. Any ideas?

var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

for (i=0; i<ilayer.layers.length; i++)

    {
        var sublayer = ilayer.layers[i];
		  
		try {
			sublayer.name = sublayer.pageItems[0].name;
		}
		catch(err) {
			try {
				sublayer.name = sublayer[0].name;
			}
			catch(err) {
				// pass
			}
		}
    }

 

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 ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

Got it working. Here's code:

var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

for (i=0; i<ilayer.layers.length; i++)

    {
        var sublayer = ilayer.layers[i];
		  
		try {
			sublayer.name = sublayer.pageItems[0].name;
		}
		catch(err) {
			try {sublayer.name = sublayer.layers[0].name;
			}
			catch(err) {
				alert(err);
			}
		}
    }

 

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 Beginner ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Hi Peter! After using this code, I am recieving a different result than expected. Please see the screenshot attached.

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

All the issues I had were to do with the types of "layers" I was trying to get the names from. For some of my "layers" they weren't actually considered layers, but groups or lines or something. That's why I put the error checking with pageItems because I discovered that Illustrator considered some of my "layers" with the names to be pageItems instead of actual layers. I would suggest learning more about that so you can customize the code to work with your project. Or perhaps you can create new literal layers and put all your stuff in them and then try it, but that kind of defeats the purpose of the code.

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 Beginner ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Thank you for 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
New Here ,
Sep 11, 2024 Sep 11, 2024

Copy link to clipboard

Copied

Maybe I am missing something here, but when i run the .jsx file it does nothing.
Can anyone 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 ,
Sep 17, 2024 Sep 17, 2024

Copy link to clipboard

Copied

LATEST

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