Findstr and goto

Hewlett-packard / Sd2100
March 3, 2010 at 17:36:53
Specs: Windows 7, 1024

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.


See More: Findstr and goto

Report •

#1
March 3, 2010 at 18:05:23
You should be using && instead of ||.

http://judago.webs.com/batchoperato...


Report •

#2
March 3, 2010 at 18:11:08
FINDSTR /C:"TEST" "%CD%\something.txt" > nul
if not errorlevel 1 (
goto :start
) else (
echo not found
goto :eof
)


=====================================
Helping others achieve escape felicity

M2


Report •

#3
March 5, 2010 at 02:16:03
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%



Report •
Related Solutions


Ask Question