Description: |
call:kBytesFree drive ret |
Script: |
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16.
|
:kBytesFree drive ret -- returns the free space of a drive in kilobytes
:: -- drive [in] - drive letter, default is c:
:: -- ret [out,opt] - varref returns number of bytes free
:$created 20060101 :$changed 20080219 :$categories FileInfo
:$source https://www.dostips.com
SETLOCAL
SET "drive=%~1"
IF "%drive%"=="" SET "drive=C:"
FOR /f "tokens=3 delims= " %%a in ('"dir %drive%\|find "bytes free""') do set free=%%a
SET "free=%free:,=%" &rem eleminate commas in number
SET "free=%free:.=%" &rem eleminate dots in number
SET "free=%free:~0,-3%" &rem divide by 1000 by cutting off the last 3 digits
( ENDLOCAL & REM RETURN VALUES
IF "%~2" NEQ "" (SET "%~2=%free%") ELSE echo.%free%
)
EXIT /b
|
|