I\'m trying to get integer of free disk space in Batch file. This is a my (very) simple code.
@echo off
wmic logicaldisk get freespace >> freespace.log
Use below code. Try replacing the caption text with deviceid if it shows ? or blank.
@echo off
setlocal
set drive=C
set free=?
rem Note: WMIC will output unicode text
wmic logicaldisk where (caption = "%drive%:") get freespace>"%temp%\free.tmp"
for /f %%A in ('type "%temp%\free.tmp"') do (set free=%%A)
echo Free space: %free% bytes
rem if exist "%temp%\free.tmp" del "%temp%\free.tmp"