Copy link to clipboard
Copied
Hello,
what is the script to delete some letters from layer?
For ex. I've "Layer XYZ" and I want "Layer XY".
Thanks for helping me!
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
....
Copy link to clipboard
Copied
at the simplest, something like this
app.activeDocument.layers['Layer XYZ'].name = 'Layer XY';
Copy link to clipboard
Copied
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
....
Copy link to clipboard
Copied
I forgot:
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....
Copy link to clipboard
Copied
ok, what's the rule?
do you want to remove the last 2 letters from All Layer Names?
Copy link to clipboard
Copied
Exact
Copy link to clipboard
Copied
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…?
Copy link to clipboard
Copied
Hello,
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[0].name;
alert(aName);
var newName = "LayerXYZ";
// Changing the new name of top level
aDoc.layers[0].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[0].name.slice(0,-3);
// Changing the new name of Layer 1
aDoc.layers[0].name = newName;
// display the new name | the result will be: Layer
alert("The new short name of this Layer is: " +newName);
Copy link to clipboard
Copied
@ mauro8282,
why is your question (posting # 2) at the same time the correct answer?
Copy link to clipboard
Copied
he marked his own post as correct...not sure why.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now