Computing.Net > Forums > Disk Operating System > I Need Help with the FIND Command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

I Need Help with the FIND Command

Reply to Message Icon

Name: Ryan
Date: February 15, 2003 at 17:59:33 Pacific
OS: Win2k
CPU/Ram: 900/768
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Qurus
Date: February 15, 2003 at 22:56:57 Pacific
Reply:

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


0

Response Number 2
Name: Ryan
Date: February 16, 2003 at 12:33:23 Pacific
Reply:

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.


0

Response Number 3
Name: IVO
Date: February 17, 2003 at 03:10:15 Pacific
Reply:

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 EXIT

Echo 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" | More

It 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.


0

Response Number 4
Name: Ryan
Date: February 17, 2003 at 14:54:54 Pacific
Reply:

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!


0

Response Number 5
Name: IVO
Date: February 18, 2003 at 02:46:38 Pacific
Reply:

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 EXIT

Echo --- >> %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 "---" | More

Set 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.


0

Related Posts

See More



Response Number 6
Name: tHe mAdd pRoFeSsOr
Date: March 15, 2003 at 04:47:36 Pacific
Reply:

find "word1" *.*>>tempfile.txt
find "word2" *.*>>tempfile.txt
find "word3" *.*>>tempfile.txt

Three 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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: I Need Help with the FIND Command

I need help on the CALL command please!! www.computing.net/answers/dos/i-need-help-on-the-call-command-please/8270.html

I need help with conventional memory BADLY!!! www.computing.net/answers/dos/i-need-help-with-conventional-memory-badly/1052.html

The FIND command www.computing.net/answers/dos/the-find-command/13233.html