Page 1 of 1

how to read from a txt file and process then write into a txt file

Posted: 26 Jan 2018 15:45
by goodywp
Hi
I have a txt file usually with 3 lines, either line 2 or line 3 could show "ECHO is off." like below:

T501-08680-0102
ECHO is off.
ECHO is off.

I would like to have a output txt file showing as below:

T501-08680-0102
no_sl
no_fk

Thanks

Re: how to read and process then write into a txt file from a text file with some strings

Posted: 26 Jan 2018 15:47
by Squashman
I guess I would go back and look at the code that was creating that file and figure out what is coded incorrectly, that is causing ECHO OFF to get output to your file.

Re: how to read and process then write into a txt file from a text file with some strings

Posted: 26 Jan 2018 15:51
by goodywp
Squashman wrote:
26 Jan 2018 15:47
I guess I would go back and look at the code that was creating that file and figure out what is coded incorrectly, that is causing ECHO OFF to get output to your file.
Actually, it is due to some lines (variable) empty, originally I added into the source file. but as requirement, it is better hidden inside the code rather exposure outside
So it is correct. whenever the second or third line empty will show ECHO IS OFF.

Re: how to read from a txt file and process then write into a txt file

Posted: 26 Jan 2018 16:45
by Squashman
So what is stopping you from using a FOR /F command to read the file. Then use the IF command to see if the line equals what you are checking. Then do something based on that statement being TRUE.

You have been shown all of this in your previous questions over the past 6 months.

Re: how to read from a txt file and process then write into a txt file

Posted: 27 Jan 2018 07:13
by goodywp
Squashman wrote:
26 Jan 2018 16:45
So what is stopping you from using a FOR /F command to read the file. Then use the IF command to see if the line equals what you are checking. Then do something based on that statement being TRUE.

You have been shown all of this in your previous questions over the past 6 months.
Could you please remove this post?
I had a work around to solve this issue. And I might share the issue later ....
Thanks