Copy link to clipboard
Copied
Hi, I would like to know if someone has a script to verify if there is a "background" layer in a file, and if there is one, it will unlocks it and rename it to for example "default". I would like to integrate it into the Script Events Manager, but if I use the one that is by default in photoshop it renames to the filename (I am not savy in scipting, I have tried to use actions but if the opened file dont have a background but a regular layer it gives me an error).
Thank you in advance
The standard script from Adobe (Presets/Scripts/Event Scripts Only/Open As Layer.jsx):
// (c) Copyright 2008. Adobe Systems, Incorporated. All rights reserved.
/*
@@@BUILDINFO@@@ Open As Layer.jsx 1.0.0.1
*/
var begDesc = "$$$/JavaScripts/OpenAsLayer/Description=Assign this to the open document event. This will promote a document with only a background layer to a layer with the document name." // endDesc
var begName = "$$$/JavaScripts/OpenAsLayer/MenuName=Open As Layer" // endName
// on l
...
Copy link to clipboard
Copied
The standard script from Adobe (Presets/Scripts/Event Scripts Only/Open As Layer.jsx):
// (c) Copyright 2008. Adobe Systems, Incorporated. All rights reserved.
/*
@@@BUILDINFO@@@ Open As Layer.jsx 1.0.0.1
*/
var begDesc = "$$$/JavaScripts/OpenAsLayer/Description=Assign this to the open document event. This will promote a document with only a background layer to a layer with the document name." // endDesc
var begName = "$$$/JavaScripts/OpenAsLayer/MenuName=Open As Layer" // endName
// on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details
$.localize = true;
try {
if ( app.documents.length > 0 ) {
var doc = activeDocument;
if ( doc.layers.length == 1 && doc.activeLayer.isBackgroundLayer ) {
doc.activeLayer.isBackgroundLayer = false;
doc.activeLayer.name = doc.name;
}
}
} // try end
catch( e ) {
// always wrap your script with try/catch blocks so you don't stop production
// remove comments below to see error for debugging
// alert( e );
}
Change from:
doc.activeLayer.name = doc.name;
To:
doc.activeLayer.name = "default";