FIND Command
find /I /N "STRING" FILE LOCATION>> "TXT FILE"
**** the lines containing the string into the text file. Easy enough.
It also **** all of the names and file paths of all the other files it scans into the text file. Even if it does not find the string.
I want to search for a string within 15 files and only **** the file names and the string line into the text file.
Ideas?
**** the lines containing the string into the text file. Easy enough.
It also **** all of the names and file paths of all the other files it scans into the text file. Even if it does not find the string.
I want to search for a string within 15 files and only **** the file names and the string line into the text file.
Ideas?
Foolproof systems don't take into account the ingenuity of fools
Comments
Note %i could be a referance like :MyFunc
My bad didn't mean to pipe dir to for.
Note there may be some line wrapping, but it should all be entered without a carriage return. Obviously substitute the string and original files to search per your needs.
In the example, I am searching for the word/string "vista" in all my text files under C:\temp. Using the /M switch in findstr tells it to only print the names of file names that match, not the actual line and string. This output is sent to the file c:\temp\findlog.log (named .log to be excluded from future *.txt searches, you can handle this in whatever way you want). Then the ampersand symbols (&&) say that if the first command run is successful, now run the "for" command, which says that for every file listed in findlog.log, search for the string "vista" and send the filename, line number and string to the c:\temp\results.log file.
HTH
Note:
If you want to save the above command line as a batch file, use 2 percent symbols instead of one in the "for" command, like so:
for /f %%F in (C:\temp\findlog.log) do find /N /I "vista" %%F >> c:\temp\results.log
(Sorry for delay been away for a few days just back into work today, doesnt time off fly??
Cheers again!!