I would like to retrieve and use the size of a file (in MB/KB) as a SmartName. How can I do that?
Procedure
This can be achieved by setting up a Script SmartName with the following content:
var localfile = "<<filespec/>>".replace("file://", "//");
var file = new java.io.File(localfile);
var bytes = file.length()
var kbytes = bytes / 1024;
var mbytes = kbytes / 1024;
mbytes.toFixed(2);
(use kbytes.toFixed(2); or bytes.toFixed(2); as last line instead of mbytes.toFixed(2); to get the value in kbytes or bytes instead of mbytes).
Esko does not provide or support Scripts, or guarantee the expected functioning of user scripts. This page merely serves as a tip.