app.preferences.rulerUnits = Units.PIXELS;
var srcDoc = app.activeDocument;
var numOfLayers = srcDoc.layers.length;
var results = "";
var fileName = srcDoc.name;
var docName = fileName.substring(0,fileName.length -4)
var theFile = srcDoc.path + "/" + docName + ".txt";
for (var i = 0; i < numOfLayers ; i++)
{
var theLayer = srcDoc.layers[i];
var lb = getLayerBounds(theLayer).toString();
results += theLayer.name + ": " + lb + "
";
}
writeTextFile(theFile, results)
alert(results);
function getLayerBounds(alayer)
{
var x1 = parseFloat(alayer.bounds[0])
var y1 = parseFloat(alayer.bounds[1])
var x2 = parseFloat(alayer.bounds[2])
var y2 = parseFloat(alayer.bounds[3])
return [x1,y1,x2,y2]
}
function writeTextFile(afilename, output)
{
var txtFile = new File(afilename);
txtFile.open("w"); //
txtFile.writeln(output);
txtFile.close();
}