Script to rename selected layers and layer sets with a prepend of user-input characters
Copy link to clipboard
Copied
Hello all,
I've got this bit of code here which will rename a layer, whether it's an art layer or a layer set, by prepending a user-input character string. I'd like it to apply this user-input character prepend rename to all active layers currently selected in the document. Any help is greatly appreciated. Thank you!
Explore related tutorials & articles
Copy link to clipboard
Copied
var aDoc = activeDocument;
var actLay = aDoc.activeLayer.layer;
if (actLay.typename == "ArtLayer") {
var newName = prompt ("Please type in current R#", actLay.name, "Rename");
try {actLay.name = newName + " • " + actLay.name;} catch (e) {};
} else {
(actLay.typename == "LayerSet") {
var newName = prompt ("Please type in current R#", actLay.name, "Rename");
try {actLay.name = newName + " • " + actLay.name;} catch (e) {};
}
Copy link to clipboard
Copied
This is not a direct answer, however, while on the general topic there is this script from Paul Riggott:
https://raw.githubusercontent.com/Paul-Riggott/PS-Scripts/master/Layer%20Name%20Edit.jsx
It can rename selected layers and layer sets. As it uses a regular expression based find/replace, if your layers have different names that will be renamed to the same name, use the following as a wildcard for the search:
.+
(period plus-sign)

