So after my previous for loop problem, I thought everything was solved and good, but little did I know, that fortune had another problem in-store for me!
Trying to extract data from my same text file "E_Summary.txt", I encountered another hair-tearing problem which was:
Content of the E_Summary File:
Code: Select all
IMPORT EXPORT DETAILS 2017
Export Details}
2157a45e9b - 15-4-2017 - To Unknown
541288t918b9s - 25-7-2017 - To KDM
--
Import Details}
124j19248I192L - 14-9-2017 - From Lahore
h7a8a99879a88 - 15-9-2017 - From Karachi
--
I wanted to extract the content from the file, assigning each line to a different variable, and dividing the content into sections. E.g: the content under the Import Details should be in ImportDetail[1], ImportDetail[2]... variables and the content under Export Details should be in ExportDetail[1], ExportDetail[2]... vars.
The only non-working and stupid piece of code that I've come up with till now is this:
Code: Select all
:ImportDetails
set ImportDetails_Cnt=0
For /f "skip=1 tokens=*" %%A IN (E_Summary.txt) DO (
if %%A == {*end*} (goto :ExportDetails)
Set "ImportDetailsTodo[!ImportDetails_Cnt!]=%%A"
Set /a ImportDetails_Cnt+=1
)
:ExportDetails
set ExportDetails_Cnt=0
set /a ImportDetails_Cnt+=3
For /f "skip=%ImportDetails_Cnt% tokens=*" %%A IN (E_Summary.txt) DO (
if %%A == {*end*} (goto :Start)
Set "ExportDetailsTodo[!ExportDetails_Cnt!]=%%A"
Set /a ExportDetails_Cnt+=1
)
I'm sure this code will be a good one to laugh at when I would've mastered the for loop, but till then, I've got to rely on the professional minds of DosTips to help me out.
Any help is greatly appreciated,
PaperTronics