You are not logged in.
Hello,
this command: FSUTIL FSINFO DRIVES
outputs something like:
Drives: A:\ C:\ D:\
1. How to get drives list, one by line?
A:\ C:\ D:\
2. How to get "Drives: A:\ C:\ D:\" in a variable's value?
Thank in advance.
Offline
That was a little more challenging that I expected, due to some weirdness with the output produced by FSUTIL (contrary to how it might appear, those aren't spaces between the items in the list.) Nevertheless, I worked around it, this should do what you ask on both counts (tested on WinXP only):
@echo off
setlocal enabledelayedexpansion
set drives=
for /f "usebackq tokens=1*" %%a in (`FSUTIL FSINFO DRIVES ^| find ":"`) do (
if /i "%%a" NEQ "Drives:" (
set "drives=!drives! %%a"
echo:%%a
) ELSE (
set "drives=!drives! %%b"
echo:%%b
)
)
set drives=%drives:~1%
echo:"%drives%"
pauseLast edited by bluesxman (2008-Mar-02 10:38:53)
Offline
This works but then you end up with "Drives:" as one of the outputs, which doesn't really matter if you are passing the variable through some command it will just fail and move to the next actual drive:
FOR /F "usebackq tokens=1" %%x IN (`FSUTIL FSINFO DRIVES ^| FIND ":"`) DO @ECHO %%x
This runs twice as fast as the fsutil approach and most importantly does not output "Drives:"
FOR /F "usebackq tokens=1" %%x IN (`MOUNTVOL ^| FIND ":\"`) DO @ECHO %%x
Working examples, output removable drive letters:
FOR /F "usebackq tokens=1" %%a IN (`FSUTIL FSINFO DRIVES ^| FIND ":"`) DO ( FOR /F "usebackq tokens=3" %%b IN (`FSUTIL FSINFO DRIVETYPE %%a`) DO ( IF /I "%%b" EQU "Removable" ECHO %%a ))
or better yet:
FOR /F "usebackq tokens=1" %%a IN (`MOUNTVOL ^| FIND ":\"`) DO ( FOR /F "usebackq tokens=3" %%b IN (`FSUTIL FSINFO DRIVETYPE %%a`) DO ( IF /I "%%b" EQU "Removable" ECHO %%a ))
Offline
See this discussion:
http://www.ss64.org/viewtopic.php?id=410
Offline
To achieve the desired format you might want to try this . . .
for /f "skip=1 tokens=*" %a in ('wmic logicaldisk get deviceid') do @echo %aLast edited by *SCRIPTER* (2009-May-24 02:47:10)
Offline
for /f "tokens=2" %%_ in ('fsutil fsinfo drives ^| more') do echo %%_
for /f "tokens=1 skip=2" %%_ in ('fsutil fsinfo drives ^| more') do (
echo %%_
)wmic logicaldisk get caption | findstr /r /v "^Caption"
for /f "tokens=3 skip=9" %%_ in ('echo list volume ^| diskpart') do (
echo %%_:
)Offline
Been playing around with this for a while using various bits and pieces
it works some of the time but not all of the time
If i use on XP for eg its fine
Using this
set "drlist="
for /f "tokens=*" %%A in ('fsutil fsinfo drives^|find /V ""') do (
set "dr=%%A"
call set "drlist=%%drlist%% %%dr:~-3%%"
)
for %%A in (%drlist%) do fsutil fsinfo drivetype %%A
but if i run it on Win 7 it returns
:\ - No such Root Directory
Press any key to continue . . .
I just cant work out whats wrong with it
Heres the output with echo on
H:\Home Backup>set "drlist="
H:\Home Backup>for /F "tokens=*" %A in ('fsutil fsinfo drives|find /V ""') do (
set "dr=%A"
call set "drlist=%drlist% %dr:~-3%"
)
H:\Home Backup>(
set "dr=Drives: C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ X:\ Y:\ Z:\ "
call set "drlist=%drlist% %dr:~-3%"
)
H:\Home Backup>for %A in (:\) do fsutil fsinfo drivetype %A
H:\Home Backup>fsutil fsinfo drivetype :\
:\ - No such Root Directory
Press any key to continue . . .
Could i have a lil help please
I may have solved my problem by using this
(for %%d in (A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z) do ^
@fsutil fsinfo drivetype %%d:) ^
| find /v "No such Root Directory"
which appears to work fine in win 7
creds goto Tima Salmi for the code
Last edited by Chimaera (2009-Dec-13 15:06:00)
Offline
For what it's worth, I have a script which makes a decent attempt at figuring out drive types (beyond what "fsutil" will show you). I think I posted it on the forum somewhere already, but here it is again anyway:
@echo off
setlocal enabledelayedexpansion
set drive=
echo:
for /f "usebackq tokens=1*" %%a in (`fsutil fsinfo drives ^| find ":"`) do (
if /i "%%a" NEQ "Drives:" (
set "drive=%%a"
) ELSE (
set "drive=%%b"
)
set label=
for /f "usebackq tokens=1* delims=\- " %%A in (`fsutil fsinfo drivetype !drive!`) do (
for /f "usebackq tokens=5*" %%U in (`vol %%A 2^>nul ^| findstr "^.Volume.in.drive...is" ^| findstr /v "^.Volume.Serial"`) do set label=%%V
set type=%%B
)
set "label=!label! "
set type=!type:~0,-1!
set drive=!drive:\=!
for /f "usebackq tokens=2*" %%R in (`subst 2^>nul ^| findstr /i /b "!drive!"`) do set type=SUBST : %%S
echo:!drive! [!label:~0,32!] !type!
)
echo:
pauseOffline
I dont know what's going on here, but my output is broken down in lines.
FSUTIL FSINFO DRIVES | find ":"
outputs to
Drives:
C:\
D:\
E:\
F:\
G:\
My CMD version is 5.2.3790 [XP x64]
Last edited by insthink (2009-Dec-14 09:31:45)
Offline
If you take the "find" off, you might find it appears on one line (on screen). Well, that's assuming XP x64 behaves like XP x86.
Offline
bluesxman wrote:
For what it's worth, I have a script which makes a decent attempt at figuring out drive types (beyond what "fsutil" will show you). I think I posted it on the forum somewhere already, but here it is again anyway:
Code:
@echo off setlocal enabledelayedexpansion set drive= echo: for /f "usebackq tokens=1*" %%a in (`fsutil fsinfo drives ^| find ":"`) do ( if /i "%%a" NEQ "Drives:" ( set "drive=%%a" ) ELSE ( set "drive=%%b" ) set label= for /f "usebackq tokens=1* delims=\- " %%A in (`fsutil fsinfo drivetype !drive!`) do ( for /f "usebackq tokens=5*" %%U in (`vol %%A 2^>nul ^| findstr "^.Volume.in.drive...is" ^| findstr /v "^.Volume.Serial"`) do set label=%%V set type=%%B ) set "label=!label! " set type=!type:~0,-1! set drive=!drive:\=! for /f "usebackq tokens=2*" %%R in (`subst 2^>nul ^| findstr /i /b "!drive!"`) do set type=SUBST : %%S echo:!drive! [!label:~0,32!] !type! ) echo: pause
Yes i tried that one m8 but it gives me this on win 7
C: D: E: F: G: [ ] : fsutil
fsinfo drivetype C
Press any key to continue . . .
Is that how its supposed to output?, or am i doing something wrong
Offline
No, that's certainly not how it's supposed to look! If you're running the code as-is, it should just work.
Knowing Microsoft, I expect they tweaked something in the format of the command output and that's what's throwing it off. They have a habit of moving things around just for the sake of it in the GUI, so probably do the same for the command line stuff. It's probably a trivial one to fix, but I'm afraid I've not got a copy of Win7 to test against.
Offline
Heres the output if that helps
H:\TS Backup Files>setlocal enabledelayedexpansion
H:\TS Backup Files>set drive=
H:\TS Backup Files>echo:
H:\TS Backup Files>for /F "usebackq tokens=1*" %a in (`fsutil fsinfo drives | fi
nd ":"`) do (
if /I "%a" NEQ "Drives:" (set "drive=%a" ) ELSE (set "drive=%b" )
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype !drive!`
) do (
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
set drive=!drive:\=!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "!drive!"`) do
set type=SUBST : %S
echo:!drive! [!label:~0,32!] !type!
)
H:\TS Backup Files>(
if /I "Drives:" NEQ "Drives:" (set "drive=Drives:" ) ELSE (set "drive=C:\ D:\ E
:\ F:\ G:\ H:\ I:\ J:\ K:\ X:\ Y:\ Z:\ " )
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype !drive!`
) do (
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
set drive=!drive:\=!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "!drive!"`) do
set type=SUBST : %S
echo:!drive! [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol Usage 2>nul | findstr "^.Volume.in.drive
...is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=: fsutil fsinfo drivetype <volume pathname>
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol Eg 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=: fsutil fsinfo drivetype C:
)
C: D: E: F: G: H: I: J: K: X: Y: Z: [ ] : fsutil
fsinfo drivetype C
H:\TS Backup Files>echo:
H:\TS Backup Files>pause
Press any key to continue . . .
Offline
Ah OK, I think I see what's going on there.
Hopefully this version should be a bit more tolerant -- but see previous disclaimer about the lack of a Win7 install to test against (the only thing I say for certain is that the changes I've made don't break it on my WinXP).
@echo off
setlocal enabledelayedexpansion
set drive=
echo:
for /f "usebackq tokens=1*" %%a in (`fsutil fsinfo drives ^| find ":"`) do (
if /i "%%a" NEQ "Drives:" (
set "drive=%%a"
) ELSE (
set "drive=%%b"
)
set drive=!drive:\=!
for %%D in (!drive!) do (
set label=
for /f "usebackq tokens=1* delims=\- " %%A in (`fsutil fsinfo drivetype %%D`) do (
for /f "usebackq tokens=5*" %%U in (`vol %%A 2^>nul ^| findstr "^.Volume.in.drive...is" ^| findstr /v "^.Volume.Serial"`) do set label=%%V
set type=%%B
)
set "label=!label! "
set type=!type:~0,-1!
for /f "usebackq tokens=2*" %%R in (`subst 2^>nul ^| findstr /i /b "%%D"`) do set type=SUBST : %%S
echo:%%D [!label:~0,32!] !type!
)
)
echo:
pauseOffline
Now we are cooking on gas
Output as follows
C: [Main Drive ] Fixed Driv
D: [Main Setup ] Fixed Driv
E: [System Reserved ] Fixed Driv
F: [Gaming Drive ] Fixed Driv
G: [ ] CD-ROM Driv
H: [USB_TOOLS ] Removable Driv
I: [Gaming Setup ] Fixed Driv
J: [ ] CD-ROM Driv
K: [ ] CD-ROM Driv
X: [Storage_Music ] Fixed Driv
Y: [Storage_Apps ] Fixed Driv
Z: [Storage_Games ] Fixed Driv
Press any key to continue . . .
Echo On output for checking
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "%D"`) do set t
ype=SUBST : %S
echo:%D [!label:~0,32!] !type!
)
)
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype C:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "C:"`) do set t
ype=SUBST : %S
echo:C: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol C: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Main Drive
C: [Main Drive ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype D:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "D:"`) do set t
ype=SUBST : %S
echo:D: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol D: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Main Setup
D: [Main Setup ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype E:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "E:"`) do set t
ype=SUBST : %S
echo:E: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol E: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=System Reserved
E: [System Reserved ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype F:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "F:"`) do set t
ype=SUBST : %S
echo:F: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol F: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Gaming Drive
F: [Gaming Drive ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype G:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "G:"`) do set t
ype=SUBST : %S
echo:G: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol G: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=CD-ROM Drive
)
G: [ ] CD-ROM Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype H:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "H:"`) do set t
ype=SUBST : %S
echo:H: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol H: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Removable Drive
)
H:\TS Backup Files>set label=USB_TOOLS
H: [USB_TOOLS ] Removable Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype I:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "I:"`) do set t
ype=SUBST : %S
echo:I: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol I: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Gaming Setup
I: [Gaming Setup ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype J:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "J:"`) do set t
ype=SUBST : %S
echo:J: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol J: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=CD-ROM Drive
)
J: [ ] CD-ROM Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype K:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "K:"`) do set t
ype=SUBST : %S
echo:K: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol K: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=CD-ROM Drive
)
K: [ ] CD-ROM Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype X:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "X:"`) do set t
ype=SUBST : %S
echo:X: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol X: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Storage_Music
X: [Storage_Music ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype Y:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "Y:"`) do set t
ype=SUBST : %S
echo:Y: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol Y: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Storage_Apps
Y: [Storage_Apps ] Fixed Driv
H:\TS Backup Files>(
set label=
for /F "usebackq tokens=1* delims=\- " %A in (`fsutil fsinfo drivetype Z:`) do
(
for /F "usebackq tokens=5*" %U in (`vol %A 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=%B
)
set "label=!label! "
set type=!type:~0,-1!
for /F "usebackq tokens=2*" %R in (`subst 2>nul | findstr /i /b "Z:"`) do set t
ype=SUBST : %S
echo:Z: [!label:~0,32!] !type!
)
H:\TS Backup Files>(
for /F "usebackq tokens=5*" %U in (`vol Z: 2>nul | findstr "^.Volume.in.drive...
is" | findstr /v "^.Volume.Serial"`) do set label=%V
set type=Fixed Drive
)
H:\TS Backup Files>set label=Storage_Games
Z: [Storage_Games ] Fixed Driv
H:\TS Backup Files>echo:
H:\TS Backup Files>pause
Press any key to continue . . .
Thx for your time Bluesxman
One small thought on this bit
C: [Main Drive ] Fixed Driv
D: [Main Setup ] Fixed Driv
E: [System Reserved ] Fixed Driv
F: [Gaming Drive ] Fixed Driv
Is it possible to get it so the word driv becomes drive
EDIT
Think ive found the bit
set "label=!label! "
set type=!type:~0,-1!
The minus 1 seems to be the culprit
Ive changed mine to 16 and it seems to be ok, but not sure if this has repurcussions on any other bits
Last edited by Chimaera (2009-Dec-15 12:06:29)
Offline
I don't recall specifically what the -1 was for, but it was probably to dodge a troublesome character that the WinXP version of "fsutil" tacked on the end of the line.
You could probably just remove the "set type=!type:~0,-1!" line altogether.
Offline
Just curious about something bluesxman
is there a similar thing to this to show network drives as well?
ive been messing with a few of the net commands and cant seem to get a simple thing that outputs in the same way
thx
Offline
If the "net use" command doesn't show it the way you want, you can always try to write a script around it.
Offline
My first post here.
Hello.
<code>
@echo off
setlocal enabledelayedexpansion
for /F "tokens=1,*" %%A in ('fsutil fsinfo drives') do set drives=%%B
:loop
if defined drives for /F %%A in ('echo %drives%') do call :drives %%A
goto :eof
:drives
echo %1
set drives=!drives:%1 =!
goto :loop
</code>
Offline
Not quite sure where ur heading there Drewfus it just flashes and exits
Thx anyway
Offline
I get;
C:\
D:\
E:\
Perhaps try it with echoing on.
Offline
I did m8 but bear in mind im running windows 7
this is the current one we are working on courtesy of bluesxman which gives more detail
@echo off
setlocal enabledelayedexpansion
set drive=
echo:
for /f "usebackq tokens=1*" %%a in (`fsutil fsinfo drives ^| find ":"`) do (
if /i "%%a" NEQ "Drives:" (
set "drive=%%a"
) ELSE (
set "drive=%%b"
)
set drive=!drive:\=!
for %%D in (!drive!) do (
set label=
for /f "usebackq tokens=1* delims=\- " %%A in (`fsutil fsinfo drivetype %%D`) do (
for /f "usebackq tokens=5*" %%U in (`vol %%A 2^>nul ^| findstr "^.Volume.in.drive...is" ^| findstr /v "^.Volume.Serial"`) do set label=%%V
set type=%%B
)
set "label=!label! "
set type=!type:~0,-1!
for /f "usebackq tokens=2*" %%R in (`subst 2^>nul ^| findstr /i /b "%%D"`) do set type=SUBST : %%S
echo:%%D [!label:~0,32!] !type!
)
)
echo:
pause
Last edited by Chimaera (2010-Jan-12 03:39:10)
Offline
This is a bit of a hack but i think it's what you want.
Requires dosdev.exe in %CD% or path.
@echo off
setlocal enabledelayedexpansion
dosdev > dosdev.txt
for /F "tokens=*" %%A in (dosdev.txt) do call :vols %%A
goto :eof
:vols
for /F "tokens=1,2,*" %%A in ('echo %*') do (
set DL=%%A
set DT=%%C
)
for /F "tokens=6,7" %%A in ('vol %DL% ^| find "Volume in drive"') do (
set label=%%A %%B
)
set LL=0
if "%label%" equ "no label." (set label=) else (
call :LL
)
if %LL%==0 (set gap=0) else set /A gap=%LL%+1
set DT= %DT%
set DT=!DT:~%gap%!
echo %DL% %label% %DT%
goto :eof
:LL
setlocal
set var=%label%
:loop
set var=%var:~1%
if not defined var (
endlocal & set LL=%LL% & goto :eof
)
set /A LL+=1
goto :loopOffline