Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

delete some text from layer

Community Beginner ,
Jan 03, 2013 Jan 03, 2013

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!

TOPICS
Scripting
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jan 03, 2013 Jan 03, 2013

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

....

Translate
Adobe
Community Expert ,
Jan 03, 2013 Jan 03, 2013

at the simplest, something like this

app.activeDocument.layers['Layer XYZ'].name = 'Layer XY';

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 03, 2013 Jan 03, 2013

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

....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 03, 2013 Jan 03, 2013

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....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2013 Jan 03, 2013

ok, what's the rule?

do you want to remove the last 2 letters from All Layer Names?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 03, 2013 Jan 03, 2013

Exact

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 03, 2013 Jan 03, 2013

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…?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2013 Jan 03, 2013

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2013 Jan 03, 2013

@ mauro8282,
why is your question (posting # 2) at the same time the correct answer?


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2013 Jan 03, 2013
LATEST

he marked his own post as correct...not sure why.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines