Reputation: 77
I would like help making a batch script to test if there is a certain amount of storage available in a drive in Winodws 7, thanks in advance.
Upvotes: 0
Views: 2253
Reputation: 41234
I had this squirreled away from a previous request.
@echo off
set "low="
for /f "tokens=3" %%a in ('dir c:\ /-p 2^>nul') do set "size=%%a"
for /f "tokens=1-4 delims=," %%a in ("%size%") do (
if "%%d"=="" set low=1
set gb=%%a
set mb=%%b
)
if %gb%%mb% LEQ 2000 set low=1
If defined low (
echo email here with %size%
echo WARNING: Drive C: has %size% free
) else (
echo Drive C: has %gb%.%mb% free GB
)
pause
Upvotes: 0