parseSize
Reads a file size such as 1.2 GB as a number of bytes.
Details #
parseSize(text) reads a size and returns bytes. KB, MB, GB, TB and PB are powers of 1000, as Finder shows them; KiB, MiB, GiB, TiB and PiB are powers of 1024. A bare number is bytes, and thousands commas are fine (1,024 bytes). Capitals don't matter, and k, m, g and t are the decimal units.
Parameters #
Takes 1 argument.
{{ parseSize(text) }}
Examples #
parseSize("1.2 GB")→
1200000000parseSize("512 KiB")→
524288Gotchas #
Unknown units fail with
parseSize() couldn't read a size.