Version: v0.8.1 - Beta.  We welcome contributors & feedback.

File.getSize

$file.getSize($units='B', $options={}) -> number

Description

Get the file size in the given units (default: 'B' = bytes).

See Number.fromBytesTo for supported units.

We recommend the following decimal units for file sizes: kB, MB, GB.

$dataFile = file'files:/data.txt'

$sizeBytes = $dataFile.getSize()
//= Ex: 5234000

$sizeMb = $dataFile.getSize('MB')
//= Ex: 5.234

Options

Option Value Description
ifExists true/false If the file does not exist, return 0 instead of triggering an error.
$missingFile.getSize('MB', -ifExists)

See Also