1.

Solve : .bat to findstr and open file containing string?

Answer»

I am not so good at this at all but im sure trying...

I am trying to get a batch file that will...
1. read a line of TEXT from a text file
2. use that line as the string to search for in all the text files in another directory
3. then when it finds that line of text, i want it to then open that file

..... is that even possible?

anyway here is the code i have, and im sure the code is gonna be embarrassingly wrong but im hoping for help....

@echo
for /F "tokens=* delims= " %%a in ('findstr /G:%C:%\need\test2.txt %C:%\Need\1\*.txt') do set var=%%a do ( start notepad "%%~a" )



currently im getting .... WELL nothing happening, batch RUNS then closesQuote

i want it to then open that file

What if it finds the text in more than one file?I had thought about that, and it shouldn't happen in this case, these numbers are all specific to certain lots. (but you are right key word here is "shouldn't"

however... if there is way way to display the file(s) found containing that string in some wort of explorer type window so you can click and open one... that would be even betterGood Luck


Discussion

No Comment Found