computing
  • 0

Findstr And Goto

  • 0

how do i find a string and then goto if found?
i mean i know how but it fails not sure why.

FINDSTR /C:”TEST” “%CD%\something.txt” || goto start

:start
{code}

but it fails.

Share

1 Answer

  1. Or like this:

    @echo off

    set string=TEST

    REM When containing whitespaces, surround full path with double-quotes:
    set file=%CD%\something.txt

    FINDSTR /C:”%string%” %file%
    if errorlevel 1 echo Did NOT find “%string%” in %file% & goto :EOF
    echo Found “%string%” in %file%

    • 0