Difference between revisions of "$bytes"
From Scriptwiki
m (fixed grammar) |
|||
(One intermediate revision by one other user not shown) | |||
Line 4: | Line 4: | ||
The '''bkmgt''' options return the result as bytes, kilobytes, megabytes, gigabytes or terabytes. | The '''bkmgt''' options return the result as bytes, kilobytes, megabytes, gigabytes or terabytes. | ||
− | Using option '''3''' would return | + | Using option '''3''' would return the best human readable style with remainders. |
The ''suf'' property appends B,KB,MB,GB or TG depending on what formatting is being used. | The ''suf'' property appends B,KB,MB,GB or TG depending on what formatting is being used. | ||
Line 10: | Line 10: | ||
[[echo]] -ag $bytes(1024,k) ;Returns ''1'' because there is 1 kilobyte in ''1024'' bytes | [[echo]] -ag $bytes(1024,k) ;Returns ''1'' because there is 1 kilobyte in ''1024'' bytes | ||
echo -ag $bytes(123456,m) ;Returns ''0.12'' because there is 0.12 megabytes in ''123456'' bytes | echo -ag $bytes(123456,m) ;Returns ''0.12'' because there is 0.12 megabytes in ''123456'' bytes | ||
+ | echo -ag $bytes(1536,3).suf ;Returns ''1.5KB'' | ||
echo -ag $bytes([[$file]]([[$sfile]]([[$mircdir]])).size).suf | echo -ag $bytes([[$file]]([[$sfile]]([[$mircdir]])).size).suf | ||
Line 15: | Line 16: | ||
echo -ag [[$replace]]($bytes(1000000),[[$chr]](44),.) | echo -ag [[$replace]]($bytes(1000000),[[$chr]](44),.) | ||
− | Returns the number | + | Returns the number specified by $bytes parameter in following form: "1.000.000". |
[[Category:Text and Number Identifiers]] | [[Category:Text and Number Identifiers]] |
Latest revision as of 10:21, 8 November 2013
Returns comma formatted filesize.
$bytes(N,bkmgt3)[.suf]
The bkmgt options return the result as bytes, kilobytes, megabytes, gigabytes or terabytes.
Using option 3 would return the best human readable style with remainders.
The suf property appends B,KB,MB,GB or TG depending on what formatting is being used.
Examples
echo -ag $bytes(1024,k) ;Returns 1 because there is 1 kilobyte in 1024 bytes echo -ag $bytes(123456,m) ;Returns 0.12 because there is 0.12 megabytes in 123456 bytes echo -ag $bytes(1536,3).suf ;Returns 1.5KB
echo -ag $bytes($file($sfile($mircdir)).size).suf
Returns the size of the file you selected in the best human readable form with its suffix appended.
echo -ag $replace($bytes(1000000),$chr(44),.)
Returns the number specified by $bytes parameter in following form: "1.000.000".