Answered
Hide layers (inside subgroups) if it's name start with "vis_"
I want to hide all layers ( inside subgroups) if the name start with "vis_"
This works with specific layer names, I tried to adapt with indexOf, no luck...
function toggleVisibility(layerName) {
var desc11 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var list6 = new ActionList();
var ref8 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
ref8.putName(idlayer, layerName);
list6.putReference(ref8);
desc11.putList(idnull, list6);
var desc = new ActionDescriptor()
var ref = new ActionReference();
var idlayer = stringIDToTypeID("layer");
ref = new ActionReference();
ref.putName(idlayer, layerName);
var desc = executeActionGet(ref);
var vis = desc.getBoolean(charIDToTypeID("Vsbl"));
var idhide = stringIDToTypeID("hide");
executeAction(idhide, desc11, DialogModes.NO);
}
toggleVisibility('Layer 1');
