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

Add Prefix or Suffix to selected layer?

Community Beginner ,
May 13, 2017 May 13, 2017

Copy link to clipboard

Copied

Is it possible to create a script that adds a prefix to the selected layer?

If the selected layer is named  "FillLayer"

and the prefix is named  TDD_

the result would be:

TDD_FillLayer

I'm not looking for a pop up dialogue window. But just the script by which i can change the prefix name there.

Thanks for any help!

Jeff

TOPICS
Actions and scripting

Views

3.9K

Translate

Translate

Report

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

Guide , May 14, 2017 May 14, 2017

#target photoshop;

if(documents.length){

var doc = activeDocument;

var prefix = "TDD_";

doc.activeLayer.name =  prefix + doc.activeLayer.name;

};

Votes

Translate

Translate
Adobe
Community Expert ,
May 13, 2017 May 13, 2017

Copy link to clipboard

Copied

Yes it is possible to rename a layer and you can get a layers by name.  I is also possible to have layers with duplicate layers names. If the are duplicate layer names  I do not know which layer would be gotten by layer getByName.

app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("Name");

JJMack

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

Any chance of sharing this wisdom?

..assuming its not complicated to create.

Thanks!

Votes

Translate

Translate

Report

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
Guide ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

#target photoshop;

if(documents.length){

var doc = activeDocument;

var prefix = "TDD_";

doc.activeLayer.name =  prefix + doc.activeLayer.name;

};

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

a little bit more precise

#target photoshop;

if ( documents.length ) {

var doc = activeDocument;

var lay = doc.artLayers.getByName ("Ebene 1");

doc.activeLayer = lay;

var prefix = "TDD_";

if ( doc.activeLayer.name.slice(0,4) != prefix ) {

    doc.activeLayer.name =  prefix + doc.activeLayer.name;

    }

};

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

Jive is buggy since weeks.

No edit is possible (and other things).

The line

doc.activeLayer = lay;

is not required.

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

Thanks, pixxxel schubser

Was getting an error with it...

SuperMerlins code fits my needs perfectly.

But thank you very much for the reply!

Jeff

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

Sure. You didn't have a layer with name "Ebene 1".

SuperMerlins code only works with the active layer. And if this layer already have the prefix - his code will nevertheless add the prefix again (and again, and again) if the script runs again.

Votes

Translate

Translate

Report

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
Explorer ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

LATEST

Is there also a easy way to make this apply to all selected layers? Not just the current layer. I've been trying to search around, but have come up empty.

Cheers!

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

Thank you very much, SuperMerlin!

...And for those interested , here's the suffix:

#target photoshop;
if(documents.length){
var doc = activeDocument;
var suffix = "_TDD";
doc.activeLayer.name =  doc.activeLayer.name + suffix;
};

Votes

Translate

Translate

Report

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 ,
May 14, 2017 May 14, 2017

Copy link to clipboard

Copied

Please read carefully all threads.

Votes

Translate

Translate

Report

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