Select only red layers of color
A document has several layers with a red color and needs to select only the first (1st) in the top-down order. How to make this a reality using jsx? Thank you.

A document has several layers with a red color and needs to select only the first (1st) in the top-down order. How to make this a reality using jsx? Thank you.

CC 2018:
function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document'), sTT('ordinal'), sTT('targetEnum'))
nOL = executeActionGet(ref).getInteger(sTT('numberOfLayers'))
bGL = !executeActionGet(ref).getInteger(sTT('hasBackgroundLayer'))
for(i = nO - bGL; i >= 0; i--) {
function ttS(v) {return typeIDToStringID(v) == 'red'}
(ref = new ActionReference()).putIndex(sTT('layer'), idx = i + bGL)
if (ttS(executeActionGet(ref).getEnumerationValue(sTT('color')))) {
(ref1 = new ActionReference()).putIndex(sTT('layer'), idx);
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1)
dsc1.putBoolean(sTT('makeVisible'), false)
executeAction(sTT('select'), dsc1); break
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.