user4426: Does anyone know of an Illustrator script that does a "Release to Layers", but renames the layers based on their group names?
I'm sure I had one ages ago, but I can't find it now...
It's very useful when importing complex AI layers to After Effects

user22375: found the non-script answer:



Select toplevel layer.
select release to layers.
Shift drag sublayers out the top layer.
(from 'learning illustrator')

user20079: I use this script from Carlos Canto. After releasing layers it will name new top level layers based on sublayer name. The link to the adobe forum is broken now so I don't think this is accessible through there anymore.
It is a little difficult to figure out how to properly select the layers  to make it work. You must select all the objects and also have the top layer selected in the layers palette, like in this screenshot.

Thanks Carlos for making this way back in 2014!
// carlos canto // 09/26/14  
// https://forums.adobe.com/thread/287812  
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 || sublayer.pageItems[0].contents;  
}


4426: <p>Does anyone know of an Illustrator script that does a "Release to Layers", but renames the layers based on their group names?</p>

<p>I'm sure I had one ages ago, but I can't find it now...</p>

<p>It's very useful when importing complex AI layers to After Effects</p>
 22375: <p>found the non-script answer:</p>

<p><div class="youtube-embed"><div>
                <iframe width="640px" height="395px" src="https://www.youtube.com/embed/AAESBjlo1-o?start=0"></iframe>
            </div></div></p>

<p>Select toplevel layer.
select release to layers.
Shift drag sublayers out the top layer.</p>

<p>(from 'learning illustrator')</p>
 20079: <p>I use this script from Carlos Canto. After releasing layers it will name new top level layers based on sublayer name. The link to the adobe forum is broken now so I don't think this is accessible through there anymore.</p>

<p>It is a little difficult to figure out how to properly select the layers  to make it work. You must select all the objects and also have the top layer selected in the layers palette, like in this screenshot.</p>

<p><a href="https://i.stack.imgur.com/I814L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I814L.png" alt="How to select layers"></a></p>

<p>Thanks Carlos for making this way back in 2014!</p>

<pre><code>// carlos canto // 09/26/14  
// https://forums.adobe.com/thread/287812  
var idoc = app.activeDocument;  
var ilayer = idoc.activeLayer;  
for (i=0; i&lt;ilayer.layers.length; i++) {  
   var sublayer = ilayer.layers[i];  
   sublayer.name = sublayer.pageItems[0].name || sublayer.pageItems[0].contents;  
}
</code></pre>
