saving drive names into variable
Posted: 30 Jun 2014 12:39
i am looking for a way to save drive names into var
we can get the drive names using this
for %a in ( 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 @if exist %i: @echo %a:
now if the output is for exmaple
c
d
e
n
i want to do something like this
set drive1=C
set drive2=d
...
i came with one way
i can save the output in a text file and then using findstr serach for names and if find one save it in a var
but i want to know is there any better way?
also if we use a command like dir
can we serach for string without saveing the output in a text file?
i think i must use for /f perhaps?
we can get the drive names using this
for %a in ( 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 @if exist %i: @echo %a:
now if the output is for exmaple
c
d
e
n
i want to do something like this
set drive1=C
set drive2=d
...
i came with one way
i can save the output in a text file and then using findstr serach for names and if find one save it in a var
but i want to know is there any better way?
also if we use a command like dir
can we serach for string without saveing the output in a text file?
i think i must use for /f perhaps?