Mobile app version of vmapp.org
Login or Join
Sims5801359

: Script to add numbers to end of AI layer names? I figure this script would be fairly easy to write since its a simple task but I know next to nothing regarding javascript. Essentially all

@Sims5801359

Posted in: #Adobe #AdobeIllustrator #IllustratorScripting

I figure this script would be fairly easy to write since its a simple task but I know next to nothing regarding javascript. Essentially all I want to do is add numbers to the layer names, the top layer being 1, the next 2, and so forth; I want these to be added to my names, not to replace them. I don't have any sublayers so that should make the script even simpler, I just can't find what I'm looking for on Google. Any help is appreciated!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims5801359

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo857

I didn't want to do this, cause this can lead to a path of: "...and also, I'd like to only rename the selected layers... oh and...", but here's the same script edited to keep the layer names.

Note that if you got layers that already contain a number in the name, this will just append a new number there, which may be less than ideal.

////START SCRIPT////
docRef=app.activeDocument;
topLayers=docRef.layers;
for(i=0;i<topLayers.length;i++){
var currLayer=topLayers[i];
var newNum=i+1;
currLayer.name = currLayer.name + newNum; // Edited this line
subLayers=topLayers[i].layers;
for(j=0;j<subLayers.length;j++){
var currSubLayer=subLayers[j];
var newSubNum=j+1;
currSubLayer.name = currSubLayer.name + newNum+"."+newSubNum; // Edited this line
subSubLayers=subLayers[j].layers;
for(k=0;k<subSubLayers.length;k++){
var currSubSubLayer=subSubLayers[k];
var newSubSubNum=k+1;
currSubSubLayer.name = currSubSubLayer.name + newNum+"."+newSubNum+"."+newSubSubNum; // Edited this line
}
}
}
////END SCRIPT////

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme