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
#target photoshop;
if(documents.length){
var doc = activeDocument;
var prefix = "TDD_";
doc.activeLayer.name = prefix + doc.activeLayer.name;
};
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");
Copy link to clipboard
Copied
Any chance of sharing this wisdom?
..assuming its not complicated to create.
Thanks!
Copy link to clipboard
Copied
#target photoshop;
if(documents.length){
var doc = activeDocument;
var prefix = "TDD_";
doc.activeLayer.name = prefix + doc.activeLayer.name;
};
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;
}
};
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.
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
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Please read carefully all threads.