Hello everyone,
I have a script I want to create and wonder if its even possible to make.
I want to click a botton or menu item, that will rename all layers that are unnamed (like generic Layer003, Layer 004, ect) and rename them according to their blending mode. So for example if a layer is named Layer004 and is an overlay layer, when you run the script it will be renamed to Overlay004.
Is this possible to make? I've never scripted before. Would really help with organizing layers.
Is it possible? Rename Layers to Blending Mode
Re: Is it possible? Rename Layers to Blending Mode
Make a loop over layers in document, then checking name of each check its blending mode if the layer name is generic to rename it to.
Re: Is it possible? Rename Layers to Blending Mode
Thats great that its possible! You sound like its not too difficult to do as well.
Do you or anyone here think you'd be willing to do it for payment? I'd be willing to pay for such a useful script.
Re: Is it possible? Rename Layers to Blending Mode
Sure, leave your E-mail in a private message to me.
So generic layers are only those starting with 'Layer' word plus they're suffixed with 3 digit numbers?
So generic layers are only those starting with 'Layer' word plus they're suffixed with 3 digit numbers?
Re: Is it possible? Rename Layers to Blending Mode
Hello Kukurykus sorry I didnt realize you replied!
Yes, generic would just be any layer with default name. Like LAYER and a number like you stated.
You think this might be simple or complicated to do?
Yes, generic would just be any layer with default name. Like LAYER and a number like you stated.
You think this might be simple or complicated to do?
Re: Is it possible? Rename Layers to Blending Mode
For me with years of experience not, just free time lately makes it harder 

Re: Is it possible? Rename Layers to Blending Mode
No problem! DO you know of a good resource to learn for myself to start?
Or a place where I can pay someone to make it for me?
Or a place where I can pay someone to make it for me?
Re: Is it possible? Rename Layers to Blending Mode
I have no time to do it for free, so if you were interested I asked you to leave your E-Mail in PM but you haven't yet 

- Stephen_A_Marsh
- Posts: 38
- Joined: Sun Aug 04, 2019 12:37 pm
Re: Is it possible? Rename Layers to Blending Mode
An old topic, lots of good stuff for a intermediate-beginner to practice and learn!
The following code is only for the active layer, I'll post code to process all layers once I am happy.
EDIT: Of course, the question of what happens if a layer blend mode changes after the layer has been renamed is hanging out there...
The following code is only for the active layer, I'll post code to process all layers once I am happy.
EDIT: Of course, the question of what happens if a layer blend mode changes after the layer has been renamed is hanging out there...
Code: Select all
/* https://www.ps-scripts.com/viewtopic.php?p=170072#p170072 */
// Active Layer to Blend Mode Name.jsx
// Stephen Marsh, v1.0 6th December 2021
#target photoshop
// If layer name = Layer 1 | Layer 02 | Layer 003 etc. (case sensitive)
if (app.activeDocument.activeLayer.name.match(/^Layer \d+/)) {
// Call function
lyrNameToBlendName();
}
function lyrNameToBlendName() {
var lyrBlendMode = app.activeDocument.activeLayer.blendMode.toString().replace(/(?:^.+\.)(.+)/, '$1');
// UpperCase default
var lyrBlendName = lyrBlendMode.replace(/LIGHT$/, ' LIGHT').replace(/MIX$/, ' MIX').replace(/COLOR$/, ' COLOR').replace(/DODGE$/, ' DODGE').replace(/BURN$/, ' BURN').replace(/LINEAR DODGE$/, 'LINEAR DODGE (ADD)');
var suffix = app.activeDocument.activeLayer.name.replace(/(?:.+)( \d+$)/, '$1');
// LowerCase optional
// var lyrBlendNameLC = lyrBlendName.toLowerCase();
// app.activeDocument.activeLayer.name = lyrBlendNameLC + suffix;
app.activeDocument.activeLayer.name = lyrBlendName + suffix;
}
Last edited by Stephen_A_Marsh on Sat Dec 11, 2021 11:55 am, edited 2 times in total.
- Stephen_A_Marsh
- Posts: 38
- Joined: Sun Aug 04, 2019 12:37 pm
Re: Is it possible? Rename Layers to Blending Mode
NOTE: I had to pull the original code for Proper Case text as it was failing (it didn't fail before posting!)...
EDIT - 11th December 2021: Here is the updated code for Proper Case conversion!
EDIT - 11th December 2021: Here is the updated code for Proper Case conversion!
Code: Select all
/* https://www.ps-scripts.com/viewtopic.php?p=170072#p170072 */
// Active Layer to Blend Mode Name.jsx
// Stephen Marsh, v1.1 11th December 2021
#target photoshop
// If layer name = Layer 1 | Layer 02 | Layer 003 etc. (case sensitive)
if (app.activeDocument.activeLayer.name.match(/^Layer \d+/)) {
// Call function
lyrNameToBlendName();
}
function lyrNameToBlendName() {
var lyrBlendMode = app.activeDocument.activeLayer.blendMode.toString().replace(/(?:^.+\.)(.+)/, '$1');
var lyrBlendLC = lyrBlendMode.replace(/LIGHT$/, ' LIGHT').replace(/MIX$/, ' MIX').replace(/COLOR$/, ' COLOR').replace(/DODGE$/, ' DODGE').replace(/BURN$/, ' BURN').replace(/LINEAR DODGE$/, 'LINEAR DODGE (ADD)').toLowerCase();
var lyrBlendPC = (sentenceCase(lyrBlendLC));
function sentenceCase(str) {
/* https://www.geeksforgeeks.org/convert-string-to-title-case-in-javascript/ */
if ((str === null) || (str === ''))
return false;
else
str = str.toString();
return str.replace(/\w\S*/g,
function (txt) {
return txt.charAt(0).toUpperCase() +
txt.substr(1).toLowerCase();
});
}
var suffix = app.activeDocument.activeLayer.name.replace(/(?:.+)( \d+$)/, '$1');
app.activeDocument.activeLayer.name = lyrBlendPC + suffix;
}