at the simplest, something like this
app.activeDocument.layers['Layer XYZ'].name = 'Layer XY';
I try to explain my problem:
I have more layers whith different names: i have to delete from all, three or for letter from the end of each name.
How can I do?
layer xyz -> layer x
layer abc -> layer a
layer house -> layer hou
I don't know how the name of layers are... because there is a script before that change them.... in other words they are variables. I only know that i have to trim that variable names of 2/3 letters....
ok, what's the rule?
do you want to remove the last 2 letters from All Layer Names?
Well there are many methods in which you could do this… establishing the rules as you have now done you could just use substring… You only need a basic loop if all your layers are top level…?
I prefer the slice-method.
Take a look at this example:
// at first - open a document, then run script var aDoc = app.activeDocument; var aName = aDoc.layers.name; alert(aName); var newName = "LayerXYZ"; // Changing the new name of top level aDoc.layers.name = newName; // display the new name | the result will be: LayerXYZ alert ("The new name of this Layer is: " +newName); // shorter Variable newName = aDoc.layers.name.slice(0,-3); // Changing the new name of Layer 1 aDoc.layers.name = newName; // display the new name | the result will be: Layer alert("The new short name of this Layer is: " +newName);
why is your question (posting # 2) at the same time the correct answer?
he marked his own post as correct...not sure why.