1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Findstr and else

Discussion in 'DOS/Other' started by zetori, Oct 6, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. zetori

    zetori Thread Starter

    Joined:
    Oct 6, 2011
    Messages:
    1
    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
     
  2. jat421

    jat421

    Joined:
    Jun 14, 2008
    Messages:
    63
    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
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1020935