Reading from a Text File and Writing to a Text File
Posted on 2005-05-09
I am trying to write a MS-DOS batch file to read from a text file called batch_bo_report_param. I am trying to read the third line of the text file (batch_bo_report_param) which looks like this:
Execution Date (YYYY-MM-DD) : =2005-03-28
Execution Month (YYYY-MM) : =2005-03
Batch Bo Report Path: =C:\MDB_BATCH_BO_REPORTS\Report\
Log Batch Bo Report Path: =C:\MDB_BATCH_BO_REPORTS\Log\
Batch Result Bo Report Path: =C:\MDB_BATCH_BO_REPORTS\Result_Report\
Logo Path Name : =C:\MDB_BATCH_BO_REPORTS\Param\KLLogo.bmp
The command that I used was this:
FOR /F "skip=2 tokens=6-8 delims=-,:= " %%i in (d:\batch_bo_report_param.txt) do @echo %%i
The output that I received after running the above command was this:
2005 03 28
My 1st Question: I am trying to read the date which is in the third line of the text file (batch_bo_report_param) and am able to do so. But why am I getting the additional lines like 03 and \MDB_BATCH...... and so on.
How should the script be re-written in order to only get the date from the third line and prevent the other lines after the third line from appearing?
My 2nd Question: At the third line of the batch_bo_report_param text file, I would like to replace the date with today's date. I have the code to generate today's date and to put today's date into variables, but how do I write these variables holding today's date into the third line at the part that has the date 2005-03-28?
Previously I had posted a question rather similar to the above, but I was given a script in VBS. I am interested in learning and getting code in MS-DOS. My understanding of VBS is very slow and I get confused. I am only looking for code for a MS-DOS batch file. I need help on this urgently.