Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, Newbie Here. I am trying to use the FIND command to search multiple files for multiple words using the OR operand. I just need to know if the files have ANY of the words i am searching for, not ALL of the words. Any help would be greatly appreciated.

Exemple if you search something like asd then you will type dir *asd* or if you search an exe or ini you will put dir *.exe or *.ini

thanks Qurus, but i am not sure if that is what i am trying to do. Example: I want to search multiple .dat and .txt files to see if they contain the word "dog" or "fish" or "cat" inside of them. i only need to know if they contain at least one, not all of those words, and then display how many of each word was found, or display the line that the word was found on.

The following script may help you, it is far from good but it works:
@Echo Off
:: XFIND.BAt Syntax: XFind FileName String [string] ...
:: Example: XFind *.bat "ECHO" "Exit" "GoTo"Set XFTemp=%0$1.tmp
Set XFPath=%1
If exist %XFTemp% Del %XFTemp%:LOOP
Shift
If "%1"=="" GoTo EXITEcho Searching %XFPath% For %1 >> %XFTemp%
For %%I in (%XFPath%) Do Find /C %1 %%I | Find /V ": 0" >> %XFTemp%
GoTo LOOP:EXIT
Type %XFTemp% | Find /V "XFIND$1" | MoreIt searches for multiple strings within the file(s) indicated (wild characters * and ? allowed). strings must be surrounded by quotes " and without blanks imbedded and are case sensitive.
If you want an hardcopy of results enter Type XFind$1.tmp > PRN in the dir where you stored the batch script.
I hope this helps.

Thanks IVO, but i am an idiot, and i cant figure out where to put the actual file names, etc. to search for. When i try to run it, (i am putting it in a batch file with some other commands) it just says this over and over:
the process cannot access the file because it is being used by another process. 0""=="" was unexpected at this time."
I tried to subsitute in the actual .txt files and the actual words to search for, but obviously i put them in wrong. If you ever stop laughing at me, (i know i am an idiot, i am new at this) could you tell me where to insert the files(ie data1.txt, data2.dat) to search in, and the words (ie "dog", "cat", "fish") to search for, in newbie terms, i would greatly appreciate it. Thanks!

First of all, Ryan, I never want you say to be an idiot; yes, you are a newbie, but I was too a long time ago. So I tested the script more accurately and found some bugs. Use the following version that produces a more clean output removing the bugs:
@Echo Off
Set XFTemp=%0$1.tmp
Set XFPath=%1
If exist %XFTemp% Del %XFTemp%:LOOP
Shift
If %1.==. GoTo EXITEcho --- >> %XFTemp%
Echo --- Searching %XFPath% For %1 >> %XFTemp%
Echo --- >> %XFTemp%
For %%I in (%XFPath%) Do Find /C %1 %%I | Find /V ": 0" >> %XFTemp%
GoTo LOOP:EXIT
Type %XFTemp% | Find /V "XFIND$1" | Find "---" | MoreSet XFTemp=
Set XFPath=To use it to search a specific file for some strings type:
XFind MyFile.dat "dog" "cat" "MOUSE" "Hello"
That will searech the file MyFile.dat for the strings dog, cat, MOUSE and Hello.
XFind A:\MyDir1\MyDir2\MyFile.txt "Ryan"
will search the file A:\....MyFile.dat for the prsence of Ryan.
If you want to search a group of files type
XFind *.txt "cat" "Dog"
that will search in ALL txt files of the current dir the strings cat and Dog.
Remember to include the strings between quotes (") and the fact they are case sensitive, i.e Dog is different from dog.
In file names and path use DOS-like format avoiding embedded blanks.
If you need more support post me again.
Have a nice day.

find "word1" *.*>>tempfile.txt
find "word2" *.*>>tempfile.txt
find "word3" *.*>>tempfile.txtThree lines in a batchfile appends all the data together into "tempfile"
The format is sloppy though cuz the lines the data were found on as well as the filename and blank lines are also appended.
But it is easy to filter out with the right utility program.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |