How to get fixed disk drive letters in three seperate text files using batch?

170 Views Asked by At

I am running the following batch program,

:hdd
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
   for %%c in (%%b) do (
      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (
         if %%d equ Fixed (
            echo %%c >hdd.txt
         )
      )
   )
)

it stores fixed disk letter to hdd.txt output on hdd.txt, D:

but, i have three fixed disks,

local disk C:
local disk D:
local disk E:

How to get three Fixed disks letter in three different text files ?

for example,

C: in hdd1.txt

D: in hdd2.txt

E: in hdd3.txt

1

There are 1 best solutions below

0
On

You could use this which doesn't require administrative privileges:

@Echo Off
SetLocal EnableDelayedExpansion
Set "i=0"
For /F "Skip=1Delims=" %%A In (
    'WMIC LogicalDisk Where "DriveType='3'" Get DeviceID'
) Do For %%B In (%%A) Do (Set/A i+=1
            Echo %%B>"hdd!i!.txt")