I am trying to create a batch file that will edit a text file to remove lines that contain a certain string and remove the line directly after that. An example of this file would look like this:
LINE ENTRY KEEP_1 BLA BLA END LINE ENTRY REMOVE_1 FOO BAR END LINE ENTRY REMOVE_2 HELLO WORLD END LINE ENTRY KEEP_2 CAT DOG END
After running the batch script I require the new file to contain
LINE ENTRY KEEP_1 BLA BLA END LINE ENTRY KEEP_2 CAT DOG END
where any line containing REMOVE_ has been deleted, as well as the corresponding 'END' line.
I have tried using the technique found here to remove the lines containing the string but it does not appear to be possible to include characters such as \r\n to check for and include the 'END' in the search. I can't do this as 2 seperate FINDSTR commands as I still require the 'END' text to be kept for the other two entries.
Using findstr /v REMOVE_
leaves me with the following:
LINE ENTRY KEEP_1 BLA BLA END END END LINE ENTRY KEEP_2 CAT DOG END
and using findstr /v "REMOVE_*\r\nEnd"
does not seem to work at all.
Just to confirm each line is definitely terminated with \r\n
.
Any help on this issue would be greatly appreciated.