I have text file in same folder as where my batch file is.
so I want my batch file to read content of the text file and depending on content of that text file I want it to perform action.
example if text file contains “Hello World” then do like Start VLC
if it doesn’t contain Hello World then do something else.
Text will update on it’s own.
here is my batch code so far, it can output the text from text file on screen.
@echo off
for /f "tokens=*" %%a in (log.txt) do call :processline %%a
pause
goto :eof
:processline
echo line=%*
goto :eof
:eof
You should use either FIND or FINDSTR. Type
HELP FINDandHELP FINDSTRfrom a command prompt to get documentation. FIND is very simple and reliable. FINDSTR is much more powerful, but also tempermental. See What are the undocumented features and limitations of the Windows FINDSTR command? for more info.You don’t care about the output of either command, so you can redirect output to nul.
Both commands set ERRORLEVEL to 0 if the string is found, and 1 if the string is not found. You can use the
&&and||operators to conditionally execute code depending on whether the string was found.You could also test ERRORLEVEL in an IF statement, but I prefer the syntax above.