contains Freedisk:

This program checks for free disk space and returns a 0 if there is enough space and a 1 if there isn't.
Usage freedisk drive (minimum bytes)

DiskSpace.bat uses CHKDSK to return the following environment variables:

 Name   Type   D e s c r i p t i o n 
 DRV   string   The drive letter 
 DRV_TYP   string   The type of file system (NTFS / FAT). 
 DRV_TOT   numeric   The total drive size, in kilobytes. 
 DRV_FREE   numeric   The free space available, in kilobytes 
 DRV_ALLOC   numeric   The allocation unit size, in bytes. 

To use DiskSpace.bat:

DiskSpace DriveLetter

DiskSpace.bat contains:

<b>
@echo off
if "%1"<h1><a name="_goto_syntax_set_DRV_1_set_DRV_DRV_if_DRV_">"" goto syntax
set DRV=%1
set DRV=%DRV::=%
if "%DRV%"</a></h1>"" goto syntax
goto begin
:syntax
@echo Syntax: DiskSpace DriveLetter
goto end
:begin
if exist %TEMP%\Diskspace.%DRV%.%computername% del /f /q %TEMP%\Diskspace.%DRV%.%computername%
REM If you have SP4, you could improve performance by using chkdsk %DRV%: /c /i > "%TEMP%\Diskspace.%DRV%.%computername%"
chkdsk %DRV%: > "%TEMP%\Diskspace.%DRV%.%computername%"
for /f "Tokens=1-9 Delims= " %%i in (%TEMP%\Diskspace.%DRV%.%computername%) do call :parse "%%i" "%%k" "%%p"
goto end
:parse
if %2<h1><a name="_of_goto_type_if_2">"of" goto type
if %2</a></h1>"total" goto tot
if %2<h1><a name="_available_goto_avail_if_2">"available" goto avail
if %2</a></h1>"in" goto units
goto end
:type
set DRV_TYP=%3
set DRV_TYP=%DRV_TYP:"=%
set DRV_TYP=%DRV_TYP:.=%
goto end
:tot
set DRV_TOT=%1
set DRV_TOT=%DRV_TOT:"=%
set /a DRV_TOT=%DRV_TOT%
goto end
:avail
set DRV_FREE=%1
set DRV_FREE=%DRV_FREE:"=%
set /a DRV_FREE=%DRV_FREE%
goto end
:units
set DRV_ALLOC=%1
set DRV_ALLOC=%DRV_ALLOC:"=%
set /a DRV_ALLOC=%DRV_ALLOC%
goto end
:end</b>