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

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 ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

Thanks a lot @femkeblanco  !

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 ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

Im getting a syntax error on line 1 when I try to run this. Any ideas? this would be a life saver for me. 

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
Guide ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

What does the error message say exactly?

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 ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

quote

What does the error message say exactly?


By @femkeblanco

 

it's probably the same error all mac users report. For some reason they all save the script as "Rich Text" instead of Plain Text.

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 ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

Carlos, that's because Text Edit on Mac has Rich Text as the default Save status. You need to go into the menu to reset to Plain Text.

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 ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

For the Mac users:


1. Copy the code posted by @CarlosCanto


var idoc = app.activeDocument;

var ilayer = idoc.activeLayer;

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

     {

          var sublayer = ilayer.layers[i];

          sublayer.name = sublayer.pageItems[0].name;

     }




2. Paste it in textEdit on Mac

3. In textEdit go to Format > Make Plain Text

4. Once that done Save the file in any format doest matter (Make sure you save the file inside Illustrator scripting folder)

5. Once saved the file, click the file and hit “Enter”. Next to your file name add .js and hit enter, click Use .js in the pop up that comes

6. And that’s it! Now go to illustrator File > Scripts > Other script > choose the JS file.

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 ,
Mar 09, 2022 Mar 09, 2022

Copy link to clipboard

Copied

That's because most people don't realize Text Edit on the Mac is set to use rich text as a default instead of plain text.

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 ,
Mar 09, 2022 Mar 09, 2022

Copy link to clipboard

Copied

@CarlosCanto - Sorry to reply to an old post, but I wanted to add my thanks! Wish I had found this many years ago.

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 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

I created an account to say x62 thanks (that's the number of layers I had to rename) for this godsend of a tool. You can truly count on the community to actually fix things that Adobe should have implemented TEN years ago.

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 ,
Mar 30, 2023 Mar 30, 2023

Copy link to clipboard

Copied

Okay, I got the script where it runs, but I don't get any layer name benefits.

 

Step 1 - I have a layer with lots of little elements in it.

Step 2 - I release those to layers (sequence), so now I have a layer full of other layers.

Step 3 - run script and still have to rename all these layers.

Previously, I would simply pull the Step 2 layers out of Layer 1 and then rename. I would rather prefer to go from Step 1 (layer with named elements) to Step 4 (all elements are on their own relevantly named layers) without having to individually name the layers. I was hoping this script would do that, but it seems to just rename the released Layer # (etc) to <layer #> with my relevant element names still trapped inside and useless when I bring it into AE.

Screen shots included of the 3 stages of "this isn't working for me and I don't know why."

 

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
New Here ,
Jul 03, 2023 Jul 03, 2023

Copy link to clipboard

Copied

I've edited Carlos's script so it sequentually names the sublayes (i.e "Item 1", "Item 2" etc).

 

To iterate, you need to run the "Release To Layers (Sequence)" option in the layers menu, then run this script on the parent layer:

var idoc = app.activeDocument;
var ilayer = idoc.activeLayer;

// Get the name of the top-most layer
var topLayerName = ilayer.name;

// Loop through the sublayers and rename them sequentially
for (var i = 0; i < ilayer.layers.length; i++) {
var sublayer = ilayer.layers[i];

// Create the new name using the top layer name and sequence number
var newLayerName = topLayerName + " " + (i + 1);

// Set the new name for the sublayer
sublayer.name = newLayerName;
}

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 ,
Aug 01, 2023 Aug 01, 2023

Copy link to clipboard

Copied

Still not working for me.

 

Step 1 - release to layers (sequence)

Step 2 - run this new updated version of the script

Step 3 - cry (see screen shot of sadness)

Step 4 - rename all these little bits by hand

 

And yes, all of my layer bits have a named item in them (see screen shot where I twirled 2 open).

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 ,
Aug 01, 2023 Aug 01, 2023

Copy link to clipboard

Copied

Hello Claire, let's try to take care of these two steps

Step 3 - cry (see screen shot of sadness)

Step 4 - rename all these little bits by hand

 

can you share a sample file to analyze? save it as pdf with Illustrator compatibility and attach it here. Or upload your ai file to Google Drive, Creative Cloud or similar and post the link here

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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

I am having the same issues. When I run the script, nothing happens. No error message, no sort of feedback. JSX file was created in Text Edit (plain text). I tried running it from Other Scripts as well as copying it over so it shows in the scripts menu. Not sure what I am doing wrong. 

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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

Disregard. I was selecting Layer 1 via the radio button and not highlighting the layer.

 

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 ,
Nov 20, 2023 Nov 20, 2023

Copy link to clipboard

Copied

Hey, 

Can anyone help me with this script please? Im following the steps but nothing happens or I get an error. Do I have to select the layers in a specific way to apply the script? 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 Expert ,
Nov 20, 2023 Nov 20, 2023

Copy link to clipboard

Copied

what's the error message you're getting? post an image of your layers panel expanded

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 ,
Nov 21, 2023 Nov 21, 2023

Copy link to clipboard

Copied

Hey Carlos,

Firstly, thanks for coming back to me.

See attached the picture of my layers, "Hada Nadal CAMBIO" is the one im trying to use the script on. 

If I "release to layers (seq)" and click the script nothing happens.

If I "release to layers (seq)" and select the group layer and click on the script, i get the error 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 ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

I found myself coming back to this discussion over the years and keep forgetting the steps I needed to do to make it work so I documented them below.

 

0. IF THE SCRIPT DOES NOTHING MAKE SURE THE FILE YOU HAVE OPEN IS AN ILLUSTRATOR FILE (.AI). If it is .svg or anything else it will not work. If this is the case, Do a File -> Save as -> and make it an illustrator file and try again.
1.  Click on the PARENT layer that has all the sub items underneath you want to separate. The layer should now be highlighted in blue in the Layers panel.

2. On the right side side menu dropdown click "Release to Layers (Sequence)"

3. You will now see that all your sub items were renamed to "Layer 1, Layer 2, Layer 3, Layer 4, etc"

4. Click on the same PARENT layer that has all the sub items that got renamed. The layer should now be highlighted in blue in the Layers panel.

5. Run the script

6. All the sub items should now have reverted back to the original name and since they are layers now you can do whatever you want with it. 

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 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Amazing simple script just saved me an hour and a half-- Wish I sought this out years ago... 
Thank you! Thank You! Thank You! 

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

Copy link to clipboard

Copied

I just spent the last two hours figuring this out and unfortunately, I still screwed it up! 
I followed the steps exactly as described, but its still renaming each layer to <Layer> rather than the original names like OP suggested. I'll include an image for reference. 
I'm running the latest Adobe Illustrator CC. 

I really appreciate you all for helping out even over a decade later! 
This is yet another thing I don't understand why Adobe hasn't just made an option by default. 

 

 

DrewRead_0-1707002829442.png

 

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

Copy link to clipboard

Copied

Hi Drew, it seems your objects are not named to begin with.

 

you have to explicitly give names to your objects before running the script. <type>, <path>, 20U are not named objects

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

Copy link to clipboard

Copied

What about the "Neurotoxin"? This is the same issue I'm running into. Is there any way to just rename every object/page item to exactly the same name just to give it a refresh? 
When I rename an object to the exact name and THEN run the script, it renames it. Any idea on what to do here?

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

Copy link to clipboard

Copied

I was thinking to maybe have a script that renames every object/page item to it's exact same name, then releasing the layers, then running your script.

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

Copy link to clipboard

Copied

it should be possible but I'm not clear, can you post before and after samples?

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