After coming across this issue twice I thought I would post it here to see if anyone knows how to get around it.
I can't seem to break out of nested loops using goto, because it looks like when it breaks out of the inner loop, the parentheses then don't match because it never reached the inner closing one.
I have narrowed this down to a very simple example
for %%a in (1,2,3) do (
for %%b in (4,5,6) do (
echo Breaking
goto :BREAK
)
:BREAK
)
This results in the error
) was unexpected at this time.
I thought maybe adding extra brackets might solve the issue but it won't help unless I know I am going to break, if it's a conditional break, it's the same problem.
Is there any easy alternative to breaking out of the inner loop back into the outer, even when it is a conditional break using if's and else's?