I am trying to move certain lines from one .txt file to another. These lines all follow a certain pattern. I have been looking at using the find command in a batch file, but this does not delete the line from the original file.
For example:
find \i pattern 'd:\example1.txt' >> 'd:\example2.txt'
Is there any way to achieve this?
Thanks in advance.
Using
findstryou can print lines that don’t match, too. So you can do it in several steps, psudocoded like this:findstr pattern input > outputfindstr /v pattern input > input-inversemove /y input-inverse inputThis should leave you with all lines matching pattern in output, and an input without those lines.
EDIT: Made the last step use move with an option to overwrite, so no need to remove the input before. I guess I (being mainly a Linux person) think of ‘rename’ and ‘move’ as the same thing, and took that overwrite for granted. So, thanks for the heads-up.