8.5.20 GetFileSize (get file size)
- Purpose
-
Gets the size of a file.
In JP1/Script 07-50 or later, the command supports large files.
- Syntax
GetFileSize (PathName [, UnitofByte])
- Arguments
-
- PathName
-
Write the full path of the file as a character string or as a variable that stores this value.
- UnitofByte
-
Specify the units in which to acquire the file size as one of the following values:
Value
Meaning
Byte
Bytes
KB
Kilobytes
MB
Megabytes
If you specify KB or MB in UnitofByte, the size is rounded up. For example, if you specify KB and the file size is less than 1 kilobyte, the command returns 1.
This value is optional. If you omit this value, Byte is assumed.
Even with a large file, if the conversion result exceeds 2,147,483,647, which is the maximum numeric value supported by JP1/Script, an error results.
- Description
-
The GetFileSize command returns the size of the specified file. If an error occurs, zero is returned.
- Note
-
Take care when specifying a file in the folder set in the environment variable ProgramFiles (normally the Program Files folder on the system drive) or WinDir (normally the Windows folder on the system drive). For details, see 1.8.2 Command behavior.
- Example
' Check the file size, and copy the file if there is enough free space on the disk. Dim path1, path2, fileSz, freeSz path1 = _SCF_+"Bkup.txt" path2 = "A:" fileSz = GetFileSize (path1) freeSz = GetDiskFreeSpace (path2, KB) If (freeSz * 1024) >= fileSz Then Copy (path1, path2) End If
- JP1/Script version
-
Supported from JP1/Script 06-00.