Re: File size
Re: File size
- Subject: Re: File size
- From: Christopher Nebel <email@hidden>
- Date: Sun, 5 May 2002 20:40:39 -0700
On Friday, May 3, 2002, at 02:28 PM, Andy Wylie wrote:
on Chew(Chomp)
set {bytes, cnt} to {{"bytes", "kB", "mB", "gB", "tB", "pB", "eB"},
0}
repeat until Chomp < 1024
set {Chomp, cnt} to {Chomp / 1024, cnt + 1}
end repeat
tell Chomp to return ((it div 1) + (it mod 1) * 100 div 1 * 0.01) &
bytes's item (cnt + 1) as string
end Chew
tell application "Finder" to set |size| to largest free block
Chew(|size|)
-- "37.89mB"
Very good, but the correct suffixes are either kB, MB, GB, TB, PB and EB
or KiB, MiB, GiB, TiB, PiB, and EiB, depending on whether you're a
traditionalist or a squeaky-clean SI citizen. (Most computer systems,
including Mac OS, use "KB" for kilobytes (actually kibibytes), which is
doubly technically wrong but pretty darn well entrenched.) See
http://physics.nist.gov/cuu/Units/prefixes.html and
http://physics.nist.gov/cuu/Units/binary.html for all the painful
details.
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.