Solved Modify Code to Extract or Output Desired Results.

September 14, 2017 at 06:24:00
Specs: Windows 10

I use this code below.

echo LIST VOLUME | diskpart.exe > C:\Users\test\Documents\output.txt

And it output the results in a text file. See the results below.

Text File:
Microsoft DiskPart version 10.0.15063.0

Copyright (C) Microsoft Corporation.
On computer: DEVIN-DSK-3

Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D DVD-ROM 0 B No Media
Volume 1 E DATA NTFS Partition 931 GB Healthy
Volume 2 B backup NTFS Partition 931 GB Healthy
Volume 3 C OS NTFS Partition 224 GB Healthy Boot
Volume 4 ESP FAT32 Partition 500 MB Healthy System
Volume 5 NTFS Partition 856 MB Healthy Hidden
Volume 6 Image NTFS Partition 12 GB Healthy Hidden


I would like the code to be modify to look for the label header "Backup" and copy or output the results from the corresponding values on the left. The expected results should look like this in a text file

Expected Results:
select volume 2
remove letter b

Is this possible to parsing the results?

message edited by vane

See More: Modify Code to Extract or Output Desired Results.

Report •

September 14, 2017 at 23:51:17
✔ Best Answer
::====== script starts here ===============
:: vane.bat 2017-09-15 13:34:58.26 GMT+7
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

for /f "tokens=1,2,4* delims= " %%a in ('find "Volume 2" ^<myfile.txt') do (
echo.%%a %%b %%c %%d
::====== script ends here =================


M2 Get custom script or take private lessons

Report •
Related Solutions

Ask Question