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.

  • 1
    forums.adobe.com/thread/577215 – Joonas Jan 14 '16 at 9:31
  • @Joonas That script appears to replace all of my layer names with "Layer 1", "Layer 2", etc. I want the numbers added to the names I currently have set – garkzen Jan 14 '16 at 9:53

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.

var currLayer=topLayers[i];
var newNum=i+1;
currLayer.name = currLayer.name + newNum; // Edited this line
  var currSubLayer=subLayers[j];
  var newSubNum=j+1;
  currSubLayer.name = currSubLayer.name + newNum+"."+newSubNum; // Edited this line
    var currSubSubLayer=subSubLayers[k];
    var newSubSubNum=k+1;
    currSubSubLayer.name = currSubSubLayer.name + newNum+"."+newSubNum+"."+newSubSubNum; // Edited this line
////END SCRIPT////
  • Nice disclaimer at the top :) ".. all I want to do is add numbers to the layer names" ... except when there already is a number at the end – oh and if there is, you cannot use that layer name/number combination again", etc. etc. – Jongware Jan 14 '16 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.