This would check for a LayerSet if a name with DOM code – so it’s fairly slow.
var check = checkForLayersetNamed(app.activeDocument, false, "thisName");
alert (check);
////// function collect all layers //////
function checkForLayersetNamed (theParent, theCheck, theName) {
/* if (!allLayers) {var allLayers = new Array}
else {};*/
for (var m = theParent.layers.length - 1; m >= 0;m--) {
var theLayer = theParent.layers[m];
// apply the function to layersets;
if (theLayer.typename == "ArtLayer") {
// allLayers.push(theLayer)
}
else {
if (theLayer.name == theName) {theCheck = true};
theCheck = (checkForLayersetNamed(theLayer, theCheck, theName))
// allLayers.push(theLayer);
}
};
return theCheck
};
Below is AM code Paul Riggott posted some time ago in connection with linking Layer Masks.
You could add a check for whether the Layer is a LayerSet, but if the name is the sole distinguishing feature this might work as a basis for your operations.
app.bringToFront();
main();
function main(){
if(!documents.length) return;
linkLayers();
}
function linkLayers(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
var Names=[];
try{
activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
for(i;i<count;i++){
if(i == 0) continue;
ref = new ActionReference();
ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
var desc = executeActionGet(ref);
var layerName = desc.getString(charIDToTypeID( 'Nm ' ));
var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
if(layerName.match(/^<\/Layer group/) ) continue;
/* you could insert your operations in an if clause here */
}
};