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:

@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
@echo Syntax: DiskSpace DriveLetter
goto end
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
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
set DRV_TYP=%3
set DRV_TYP=%DRV_TYP:"=%
set DRV_TYP=%DRV_TYP:.=%
goto end
set DRV_TOT=%1
set DRV_TOT=%DRV_TOT:"=%
set /a DRV_TOT=%DRV_TOT%
goto end
set DRV_FREE=%1
goto end
set DRV_ALLOC=%1
goto end