I took a look at Photoshop CS5 Scripting Guide and Photoshop CS5 JavaScript Reference, but I couldn\'t find out a method to write text to a plain text file. Is there any way to
Here's what you need: It's pretty basic. It'll loop over the layers (no layersets!!) and save out the layer name and the layer bounds for each layer.
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 + "\n";
}
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();
}