Page 1 of 1

New paramater for 'get' . . . ? (file size needed!)

Posted: 20 Nov 2010 18:27
by Biggynuff
Hi Don and fellow XYers 8)

Not sure if this currently exists, but is there a script command that can return the file size of a selected file in the list? I've looked at 'get' etc but there doesn't seem to be a parameter to obtain this

What I'd like to do is look at writing a simple script that takes all items selected on the list and copies their file size (in whatever display units) to the comment field

This would be quite useful at times, as having XY display the file sizes each time a certain folder is opened can take a while, and they disappear when I look elsewhere in that tab :lol:

No worries if this isn't possible. But I bet it already is and many of you are now laughing at how stupid I am :roll:

Thanks!

Biggy

Re: New paramater for 'get' . . . ? (file size needed!)

Posted: 20 Nov 2010 18:46
by Biggynuff
Solved!

I am humbled by XY. Yet again 8)

Spent ages thinking about this, then the 'property' command jumped straight into my brain. Incredible Don :lol: Now I just need to work out how to display the size (returned as bytes) to mb or gb as appropriate and I'm there

Or rather, a bit closer before I become overcome with scripting mental health syndrome and ask for more help :P

Re: New paramater for 'get' . . . ? (file size needed!)

Posted: 20 Nov 2010 19:24
by Stefan
Biggynuff wrote:Solved!
the 'property' command
or
Scripting Commands Reference > report()
{Size KB} KB
{Size B} Bytes (no suffix)
{Size RAW} Raw bytes (no thousand separators)
{Size MB} MB
{Size GB}

or
User Menu Commands > <cursize>
Now I just need to work out how to display the size (returned as bytes) to mb or gb as appropriate and I'm there
formatbytes()
http://www.xyplorer.com/xyfc/viewtopic. ... 530#p54530

Re: New paramater for 'get' . . . ? (file size needed!)

Posted: 20 Nov 2010 19:32
by admin
Both retrieve the size for the current file:

Code: Select all

text report("{Size KB}",1);
text formatbytes(property("Size"), "KB");
report() should be a little faster than property()

Re: New paramater for 'get' . . . ? (file size needed!)

Posted: 20 Nov 2010 20:46
by Biggynuff
Now, here's a thing . . .

Why, why, WHY? :shock: did I know when I posted that question that, not only would XY be able to do what I wanted, but be able to do if far better than I had imagined

You guys are just awesome 8)

Thank you very much, always appreciated

Biggy