My problem is to create a batch script file for Windows and iterate through a lot of files and find every file which has a line that contains two specified strings. So if the whole file contains those strings, that's not good enough, they should be at the same line.
For example, I have 5 files which contains the following:
1st: apple:green
2nd: apple
green
3rd: green
apple
4th: apple: yellowgreen
5th: apple: green
It should return the filenames of the first, fourth and fifth file.
Here is what I have:
FINDSTR /s /i /m "apple green" *.txt | FINDSTR "\MyDirectory" >> results.txt
How should I modify this to make it work?
findstr /i /s /m /r /c:"apple.*green" /c:"green.*apple" *.txt
EDITED TO WORK WITH FINDSTR
This regex worked for me:
"apple.*green green.*apple"
Also, your write to file command with the pipe did not work for me (perhaps I'm missing something). If it doesn't work for you, perhaps this will:
FINDSTR /s /i /m "apple.*green green.*apple" *.txt >> results.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With