Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help with batch file and IF command  (Read 3465 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
Help with batch file and IF command
« on: October 17, 2006, 06:03:05 PM »
I am trying to write a batch file on a Windows 2003 Server that will do two things to hopefully make my life a little easier.  The first thing I want it to do is search through a log file and see if a word or phrase exists.  Second if it finds a match in the log file I want it to email the log file to me.

I some what have a working file for each piece but am unable to get them to work together.  For the search piece I am able to run this:

find /i /c "test" "D:\Housekeeping Scripts\Logs\Test.txt"

I was redirecting this into another txt file where it would store:


That works, and I can email the log file to myself everytime the script runs whether it has found a match or not but what I really want if for it to only email it to me if it finds a match.  I can't seem to tell if find is supposed to return a result code or not.

What I would like to see is something like this:

if (find more than one match)
   send me an email (have a tool for this already)

Was trying to just use the DOS IF command but I couldn't get it to work.  It doesn't have to be the DOS IF command though but it does have to be something I can incorporate into other scripts.

Any help would be greatly appreciated.