I want to display all the attached diskdrive model, name, index and size in command line I am using the below simple code
wmic diskdrive GET index,caption,name,size /format:table
Caption Index Name Size SAMSUNG SSD PM830 2.5" 7 0 \\.\PHYSICALDRIVE0 256052966400 Seagate backup plus 1 \\.\PHYSICALDRIVE1 536870912000
I want the same output as the above except that i would like the size to be displayed in GB
I think there is some way to do that using for loops and temp vb files.
I am specifically looking for windows cmd code. Can anybody help?
I am able to do the size conversion and display it on cmd
for /f "tokens=1,2" %a in ('WMIC DISKDRIVE GET Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh.echo "%a" ^& " size=" ^& FormatNumber^(cdbl^(%b^)/1024/1024/1024, 2^)^& " GiB" > %temp%\tmp.vbs & @if not "%b"=="" @echo( & @cscript //nologo %temp%\tmp.vbs & del %temp%\tmp.vbs
\\.\PHYSICALDRIVE0 Size=238.47 (GB)
But i am still not able to display the model name correctly.. I am just not able to get my for loop to run as intended (in my case the model name has spaces in between The below code works to just get the models printed.
for /f "tokens=1-5 skip=1" %a in ('wmic diskdrive GET model') do @echo. %a %b %c %d %e
SAMSUNG SSD PM830 2.5" 7
Can someone help me in combining both the codes such that it displays like
SAMSUNG SSD PM830 2.5" 7 \\.\PHYSICALDRIVE0 Size=238.47 (GB)