I am trying to get Model and Size of all local disks.
I want to output on one line for each disk.
Example: Model Samsung Size 500GB
@echo off
for /f "tokens=2 delims==" %%d in ('wmic diskdrive get Model,Size /value') do (
set Model=%%d
set Size=%%d
)
echo Model %Model% Size %Size%
pause
But nothing.
As model descriptions may contain spaces, you need to format the output as csv
, so the output is delimited by commas (I hope there aren't model descriptions that contain commas - I didn't see one so far).
Without /value
each disk is listed in one line (Node,Model,Size
), so you need tokens=2,3
. Add a skip=2
to remove the header line and add your fixed strings to the final output:
for /f "skip=2 tokens=2,3 delims=," %%a in ('"wmic diskdrive get Model,Size /format:csv"') do @echo Model %%a Size %%b