file size

Prev Next

Function Names

file size

Description

Returns the size of the files matching the path name. __Wildcards_ are allowed, where sum the size of all files found inside the specified directory are summed. Subdirectories will not be touched. Directory entries do not attribute to the total size, even if some operating systems report a non-zero size for subdirectories.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
Opt. 1
input
string path and file name

Specify file name (in working directory) or combination of path and file name.

Return value

TypeDescription
numeral Total size

Size of all files identified, summed, unit is bytes. -1 if not found

Exceptions

Specified file name is a directory

Examples

               // Function 'string' adds thousand separators to make numbers readable
               echo( str( file size( system info[bin directory] + "\b4p.exe" ), "#,000", local ) );   // Finds a file in Windows
               echo( str( file size( system info[bin directory] + "/b4p" ),     "#,000", local ) );   // Finds a file in Linux/MacOS
               echo( file size( "Non-existing File.txt" ) ); // -1

Output

1'707'520
-001
-1
Try it yourself: Open LIB_Function_file_size.b4p in B4P_Examples.zip. Decompress before use.