Page 1 of 1

Search for EXACT word using a Batch file - Help!

Posted: 29 Apr 2017 12:49
by val5662
I have a folder with one hundred and some htmls.I want to find an exact match to any complete word I search for and display it in a text file.The latest attempt still failed:

for %%f in (*.html) do findstr /m /p /c:"cop.rar" "%%f" >> exact-results.txt

What the above only does is shows the results of the name.html files that the word cop is in.
Examples it found: 69cop.rar , 75cop.rar , lastcop.rar , anothernamecop.rar
No good....what I want is the EXACT word only that I search for.
If I search for cop.rar , I only want the name of the html(s) that cop.rar would be in.Thanks for your help!
Val

Re: Search for EXACT word using a Batch file - Help!

Posted: 29 Apr 2017 13:22
by aGerman
Use regular expressions (option /r) and word boundaries.

Code: Select all

findstr /rmpc:"\<cop\.rar\>" "%%f"


Steffen

Re: Search for EXACT word using a Batch file - Help!

Posted: 29 Apr 2017 15:47
by val5662
Steffen...
Thanks! I appreciate it a bunch.This works like a charm!

for %%f in (*.html) do findstr /rmpc:"\<cop\.rar\>" "%%f" >> found-xact-complete-name.txt

Problem solved... :D

Val