I have a DIR that I occasionally need to clean up. It contains a bunch of .txt files and in those files are any number of lines. There is one particular line (Error: Invalid Required Field Subject_ID) that is expected. I am looking for a way to search through all the files and delete any of the ones that only contain the one error and leave the file if it has any other errors besides the expected one.
Here is an example of one file. (This one would need to not be deleted because of the unexpected error on line one)
120402140141_00002.txt Error: Some_other_error
120402140500.txt Error: Invalid Required Field Subject_ID
120402140500_00002.txt Error: Invalid Required Field Subject_ID
Update: I found this on another post.
for %%j in (*.txt) do type "%%j" | find /I "Error: Invalid Required Field Subject_ID" >nul || echo.%%j >> _pass_fail_results.log
It works, but it does not list any of the files that have other errors. If one string is matched it goes on to the next file. So in this case my _pass_fail_results.log is empty. It does however list a file in the if log if i delete all but the unexpected string.