There you go buddy:
var doc = app.activeDocument; var currentUnits = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.PIXELS; var fileName = doc.name; var fileSize = (File(doc.fullName).length / (1024 * 1024)).toFixed(2); var fileWidthPx = doc.width.value; var fileHeightPx = doc.height.value; var fileResolution = doc.resolution; var fileWidthInch = (fileWidthPx / fileResolution).toFixed(6); var fileHeigthInch = (fileHeightPx / fileResolution).toFixed(6); var colorMode = doc.mode.toString().split("."); app.preferences.rulerUnits = currentUnits; var outputString = fileName + "\t" + fileSize + " mb\t" + fileWidthPx + "\t" + fileHeightPx + "\t" + fileWidthInch + "\t" + fileHeigthInch + "\t" + fileResolution + " DPI\t" + colorMode + "\n"; var logFile = new File ("~/desktop/File Info Report.txt"); logFile.open('a'); logFile.write(outputString); logFile.close(); doc.close(SaveOptions.DONOTSAVECHANGES);
I was hoping for advice but this will work! I am going to figure out what you did. Then I will try to make it change the formula for determining the file size based on file name substring. I appreciate your help immensely!
Use this formula for file size
var fileSize = (File(doc.fullName).length / (1000 * 1000)).toFixed(1);
Both equations work.
Yajiv's equation will give the file size as calculated on a mac, and i believe on linux based systems.
Tomas's equation gives Windows interpretation of MB and GB.
I made a variable each so thanks to both of you.