Using NTFSInfo.exe,
I have scripted DrvInfo.bat to return a volume's size, free space, and allocation unit.
The syntax for using DrvInfo.bat is:
DrvInfo DriveLetter DSize FSpace Alloc
Where:
DriveLetter is the volume's drive letter, with or without the colon (:).
DSize is a call directed numeric environment variable that will contain the volume's size, in megabytes (MB).
FSpace is a call directed numeric environment variable that will contain the volume's free space, in megabytes (MB).
Alloc is a call directed numeric environment variable that will contain the volume's Allocation Unit size, in bytes.
DrvInfo.bat contains:
@echo off if \{%4\}==\{\} @echo Syntax: DrvInfo DriveLetter DSize FSpace Alloc&exit /b 1 setlocal ENABLEDELAYEDEXPANSION set work=%1 set drive=%work:~0,1% if not exist %drive%: @echo DrvInfo: %1 does NOT exist&endlocal&exit /b 2 @echo Volume size :>%TEMP%\DrvInfo.tmp @echo Free space :>>%TEMP%\DrvInfo.tmp @echo Bytes per cluster :>>%TEMP%\DrvInfo.tmp set /a cnt=0 for /f "Tokens=2 Delims=:" %%a in ('ntfsinfo %drive%^|Findstr /B /G:%TEMP%\DrvInfo.tmp') do ( set /a cnt=!cnt! + 1 call :setit!cnt! %%a ) del /q %TEMP%\DrvInfo.tmp endlocal&set /a %2=%DSize%&set /a %3=%FSpace%&set /a %4=%Alloc% exit /b 0 :setit1 set DSize=%1 goto :EOF :setit2 set FSpace=%1 goto :EOF :setit3 set Alloc=%1
0 comments
Hide comments