I have the code:
Code: Select all
@echo off
setlocal disableDelayedExpansion
set file=test.txt"
set "search=test"
for /f "delims=" %%A in ('findstr /i /c:"%search%" %file%') do (
set "ln=%%A"
echo %search%
endlocal
)
if not defined _"%ln%" (goto :error)
:BreakFOR ()
::(
for /l %%! in (
1, 1, *
) do (
%= break the loop if condition met =%
if 1 equ 0 goto :BreakFOR "{}"
)
::)
:BreakFOR {}
pause
This code is supposed to search for a string in a text file and do something if the string is found.
The next part is supposed to break the for string after the string has been found and the action carried out. I plan to have another occurrence of this code directly after this one, so once the loop has been broken the batch file will go on to the next occurrence of this code.
Now, all this code does not work. It just flashes cmd and says "the syntax of the command is incorrect".
Could you help me please,
Regards,
Rileyh