I am currently working on a script to verify my images. Here are the criteria I need to validate:
- Determine the number of layers and pathItems in the document - relatively straightforward.
- Identifying the names of 3 specific layers: I have hit a roadblock here
- Ensuring that these 3 layers are of type NORMAL - not smart objects or solid colors...
https://i.sstatic.net/lLeNn.png
#target photoshop
var doc = app.activeDocument;
var pLen = doc.pathItems.length;
var pArray = [];
var nLen = doc.layers.length;
var cArray = [];
if (nLen != 3)
{alert ("Incorrect structure")}
else if (pLen != 2 )
{alert ("Incorrect path item")}
else {for (var i=0; i<nLen; i++)
{if (doc.layer[i].getByName ("Freisteller") == false || doc.layer[i].getByName ("Hintergrund") == false || doc.layer[i].getByName ("Hintergrund BR") == false )
{alert ("Invalid layer name")}
}
}
I have attempted another solution but it is not functioning as expected
#target photoshop
var doc = app.activeDocument;
var pLen = doc.pathItems.length;
var pArray = [];
var nLen = doc.layers.length;
var cArray = [];
var layerName = ["Freisteller", "Hintergrund", "Hintergrund BR"];
if (nLen != 3)
{alert ("Incorrect structure")}
else if (pLen != 2)
{alert ("Incorrect path item")}
else {for (var i=0; i<nLen; i++)
{if (doc.layer[i].getByName ("Freisteller") != layerName || doc.layer[i].getByName ("Hintergrund") != layerName || doc.layer[i].getByName ("Hintergrund BR") != layerName )
{alert ("Invalid layer name")}
}
}
Your assistance in resolving this issue would be greatly appreciated