Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Search Search
Search for:
Tech Support Guy > > >

Findstr and else


(!)

zetori's Avatar
zetori zetori is offline
Junior Member with 1 posts.
THREAD STARTER
 
Join Date: Oct 2011
Experience: Beginner
06-Oct-2011, 03:50 AM #1
Findstr and else
Hi

I'm trying to write batch file that could find a user given word from user given directory\file. If founded, calls a second batch.

I quite new and don't have much clue what to do with this, but something like this:

Code:
 
set /p findwhat = Type word: 
set /p findwhere = Type where to find: 
for /F "tokens=1,2,3,* delims=;" %%i IN ('findstr /i "%findwhat%" %findwhere%')
IF EXIST (call batch1.bat) ELSE ECHO not found at %findwhere%
exit
Could you help me with this one, please

Thank you
jat421's Avatar
jat421 jat421 is offline
Member with 63 posts.
 
Join Date: Jun 2008
24-Oct-2011, 12:52 PM #2
I would rather do something simple like

Code:
@echo off
set /p findwhat= Type word: %=%
set /p findwhere= Type where to find: %=%

PUSHD %findwhere%
Findstr /s /m "%findwhat%" *.*
IF %ERRORLEVEL% EQU 0 (echo found) ELSE (echo not found)
POPD
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑