Skip to main content
PrepressPro1
Legend
June 28, 2017
Question

Renaming Sub-Layer

  • June 28, 2017
  • 1 reply
  • 563 views

I have this tiny script to rename a Sub-layer which works the first time I use it, then it adds to the existing sub-layer name when I run it after the first time.

var docRef = activeDocument;   
var sel = docRef.selection;   
for (var i=0; i < sel.length; i++)   
     sel.name = "CUTTER_B" + sel.name;

Any way to get this to consistently rename the sub-layer?

This topic has been closed for replies.

1 reply

pixxxelschubser
Community Expert
Community Expert
June 28, 2017

Hi PrepressPro1

your code only works with page items - not with sublayers.

Unfortunately you didn't answer one month ago.

select by layer name

"… is this "sublayer" really a sublayer? Or a grouped item instead? …"

Same question again.

For selected page items you can do something like this

var docRef = activeDocument;

var sel = docRef.selection;

for (var i=0; i < sel.length; i++) {

    var nme = sel.name.replace("CUTTER_B","");

    sel.name = "CUTTER_B" + nme;

}

Have fun

PrepressPro1
Legend
June 28, 2017

It is an object on a sub-layer. Sorry for the hiatus in my posting. Projects get back burnered with the press of production work.  Thank you for your reply.