Copy link to clipboard
Copied
Hi, you can try the following script
var _layers = app.activeDocument.layers;
for (var l = 0; l < _layers.length; l++) {
var _textItem = _layers[l].groupItems[0].textFrames[0];
if (_textItem.name != '') {
_layers[l].name = _textItem.name;
}
else {
_layers[l].name = _textItem.contents;
}
}
The above script will work assuming your layer structure is same for all. That means, Each layer will have one group and that group will atleast single textframe. If there
...Copy link to clipboard
Copied
Hi, you can try the following script
var _layers = app.activeDocument.layers;
for (var l = 0; l < _layers.length; l++) {
var _textItem = _layers[l].groupItems[0].textFrames[0];
if (_textItem.name != '') {
_layers[l].name = _textItem.name;
}
else {
_layers[l].name = _textItem.contents;
}
}
The above script will work assuming your layer structure is same for all. That means, Each layer will have one group and that group will atleast single textframe. If there are multiple textframes inside teh group, it will pickup the first one and use its name if exists.
Copy link to clipboard
Copied
I will add my own version. The interface allows you to manage the renaming in a flexible way. The script first collects all text objects in the layer and then takes the first or the last one for the layer name.
https://github.com/creold/illustrator-scripts/blob/master/md/Layer.md#renamelayerastext
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more