When a single USB is connected, the device capacity in gigabytes are calculated correctly.
But, when I tried to connect one more USB flash drive, the newly connected flash drive's capacity is displayed incorrectly. (way bigger)
Is this weird only for me?
Code: Select all
@echo off setlocal enabledelayedexpansion :: https://superuser.com/questions/1192107/wmic-output-property-value-without-property-name/1192171#1192171 for /f "tokens=* skip=1" %%a in ('"wmic diskdrive where(InterfaceType="USB") get Size | findstr ".""') do ( set "size=" set "bytes=" set "kb=" set "mb=" set "gb=" set "size=%%a" set "bytes=!size:~0,-4!" set /a kb = bytes/1024 set /a mb = kb*100/1024 set /a gb = mb/1024 set /a gb = !gb:~0,-1! echo !gb!GB :: Output :: 19GB (actually 7GB USB) :: 14GB (this one correct) ) pause