Reputation: 43
I have a batch file that I want to just output 2 lines from this command:
(
echo sel vol c
echo detail vol
echo exit ) | diskpart.exe | findstr "Volume"
Output of the diskpart
command is:
Offline : No
BitLocker Encrypted : No
Installable : Yes
Volume Capacity : 953 GB
Volume Free Space : 6057 MB
(Includes a blank space at the bottom) I want to output the 2 lines with Volume Capacity and Volume Free Space
Trying something like:
@ECHO OFF
SETLOCAL
for /F %%e IN ('(echo sel vol c^&echo detail vol^&ECHO exit^) ^| diskpart.exe ^| findstr "Volume"') do set /a lines=%%e
echo %lines%
set /a startLine=%lines% - 3
echo %startLine%
GOTO :EOF
Not working :(
Upvotes: -1
Views: 35
Reputation: 80173
FOR /f "delims=" %%e IN ('(echo sel vol c^&echo detail vol^&ECHO exit^) ^| diskpart.exe ^| findstr "Volume"') DO CALL SET "line1=%%line2%%"&SET "line2=%%e"
SET lin
the call set
will set line1
to the contents of line2
without using delayedexpansion
.
Upvotes: 0