CheckDiskFree
Purpose
CheckDiskFree determines if a disk's free space passes the test of the provided parameters and returns an ERROR_LEVEL, which
may be used and act upon in batch files.
Download
CheckDiskFree
Installation
None. Download the ZIP file, extract the included executable and run it.
Please note: this is a console application. You should run it from a command prompt.
Use case(s)
-
-
Send automated (warning) messages when the free spaces on a disk is below/above a certain size.
-
Determine if a file fits on a disk.
Syntax
CheckDiskFree /d=<disk/drive> /s=<size> /c=<compare argument>
Parameters:
-
/d = drive to test
-
/s = size to compare against, the following units are supported:
-
<omitted> - bytes
-
kb - kilobytes (1kb = 1024 bytes)
-
mb - megabytes (1mb = 1024 kb)
-
gb - gigabytes (1gb = 1024 mb)
-
tb - terrabytes (1tb = 1024 gb)
-
/c = comparison operator to use, where the following numbers are allowed:
-
-2 = lesser than
-
-1 = lesser than or equal to
-
0 = equal to
-
1 = greater than or equal to
-
2 = greater than
Examples
CheckDiskFree /d=d: /s=1000000 /c=1
Determine if the available free space on hard drive d: is greater than 1 million bytes.
CheckDiskFree /d=c: /s=512mb /c=-2
Determine if the available free space on hard drive c: is lesser than or equal to 512 megabytes.
Upon exit, CheckDiskFree returns one these ERROR_LEVEL values:
-
0 - the test passed
-
1 - the test failed
-
50 - drive not found
-
100 - invalid parameter(s) passed
-
255 - Other (application) error
Source code
The PowerBASIC source code is available at Github
Known issues / limitations
Version
-
1.0.3 - October 2018
-
Fixed a localisation issue where the free disk space in bytes was truncated.
-
1.0.2 - May 2017
-
Compiler glitch workaround.
-
1.0 - September 2012