Reputation: 83
I want to set the command outpus (multiple lines) as variables, depending on how many lines there are. First I want to export all accessable drives on the computer to a txt file:
wmic logicaldisk get name>drivesvar.txt
Then read out these lines again and set the different drives as variables.
I tried alot witf for /f commands, but it didnt work so far. Would be glad, if someone could help me ! Thank you in advance.
Upvotes: 1
Views: 602
Reputation: 56188
you don't need a file:
@echo off
setlocal enabledelayedexpansion
set i=0
for /f "tokens=2 delims=:=" %%a in ('wmic logicaldisk get name /value ') do (
set /a i+=1
set drive[!i!]=%%a
)
set drive
If you need the colon, just add it at set drive[!i!]=%%a:
(I removed it (as one of several methods) to get rid of the unusual wmic
line endings)
Upvotes: 3