Copy link to clipboard
Copied
below script working good for rename selected layers. but when there is clipping mask layers then clipping mask layers also renamed automatically.
so i want to rename selected layers except clipping mask
var newName =("layer name", "Auto_bmd");
var layers = getSelectedLayers();
for (var i = 0; i < layers.length; i ++){
layers[i].name = newName;
}
//get the list of multiple selected layers
photoshop%CA%A3%BF%F4%A5%BB%A5%EC%A5%AF%A5%C8
function getSelectedLayers(){
var idGrp = stringIDToTypeID( "groupLayersEvent" );
var descGrp = new ActionDescriptor();
var refGrp = new ActionReference();
refGrp.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Trgt" ));
descGrp.putReference(charIDToTypeID( "null" ), refGrp );
executeAction( idGrp, descGrp, DialogModes.ALL );
var resultLayers=new Array();
for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}
var id8 = charIDToTypeID( "slct" );
var desc5 = new ActionDescriptor();
var id9 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id10 = charIDToTypeID( "HstS" );
var id11 = charIDToTypeID( "Ordn" );
var id12 = charIDToTypeID( "Prvs" );
ref2.putEnumerated( id10, id11, id12 );
desc5.putReference( id9, ref2 );
executeAction( id8, desc5, DialogModes.NO );
return resultLayers;
}
var nm = "NewName";
var selected = get_selected_layers_id();
for (var i = 0; i < selected.length; i++)
{
select_layer(selected[i]);
app.activeDocument.activeLayer.name = nm;
}
select_layers(selected);
//////////////////////////////////////////////////////////////
function select_layer(id)
{
try {
var r = new ActionReference();
r.putIdentifier(stringIDToTypeID("layer"), id);
var d = new ActionDescriptor();
Copy link to clipboard
Copied
Copy link to clipboard
Copied
ok. can anybody provide me function for same.
Copy link to clipboard
Copied
var nm = "NewName";
var selected = get_selected_layers_id();
for (var i = 0; i < selected.length; i++)
{
select_layer(selected[i]);
app.activeDocument.activeLayer.name = nm;
}
select_layers(selected);
//////////////////////////////////////////////////////////////
function select_layer(id)
{
try {
var r = new ActionReference();
r.putIdentifier(stringIDToTypeID("layer"), id);
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
//////////////////////////////////////////////////////////////
function select_layers(ids)
{
try {
var r = new ActionReference();
for (var i = 0; i < ids.length; i++) r.putIdentifier(stringIDToTypeID("layer"), ids[i]);
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
//////////////////////////////////////////////////////////////
function get_selected_layers_id()
{
try {
var selected = new Array();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("targetLayersIDs"));
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var list = executeActionGet(r).getList(stringIDToTypeID("targetLayersIDs"));
for (var i = 0; i < list.count; i++) selected.push(list.getReference(i).getIdentifier());
return selected;
}
catch (e) { throw(e); }
}
Copy link to clipboard
Copied
thank you so much sir... its working
please help me for another problem
https://community.adobe.com/t5/photoshop/auto-clipping-mask-problem/m-p/11418869?page=1