I am writting a script to check my images. Here is what I need to check:
- Count layers and pathItems in document - it's not too hard for me.
- Name of 3 layers: I stuck here
- I also want to check these 3 layers kind is NORMAL - not a smartobject or solid color...
#target photoshop
var doc = app.activeDocument;
var pLen = doc.pathItems.length;
var pArray = [];
var nLen = doc.layers.length;
var cArray = [];
if (nLen != 3)
{alert ("Wrong structure")}
else if (pLen != 2 )
{alert ("Wrong 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 ("Wrong layer name")}
}
}
I aslo tried this but it doesn't work
#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 ("Wrong structure")}
else if (pLen != 2)
{alert ("Wrong 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 ("Wrong layer name")}
}
}
Please help me to fix it

You need to look for
typename == "ArtLayer"for normal, standard art layers, andlayer.kind == "LayerKind.SMARTOBJECT"for smart objects. And layer.isBackgroundLayer == true for background layers.Your script didn't work as "getbyname" isn't quite what it says.
Will get the layer called "Freisteller", if it exists. Also if there are several layers called that it'll grab the first. You were trying to "get" it from layer i.
This is your script with a couple of changes.
Also, I think this might help you out.