MY goal is to compare two files line by line and capture the changes. For that i am using two nested loops. I am stuck with braking the inner loop on some condition.
I am using label outside the inner loop for break it, but not working. It goes to label and terminate outer loop also.
@ echo off
SETLOCAL EnableDelayedExpansion
for /F "skip=8 tokens=* delims=." %%a in (sample.txt) do (for /F "skip=8 tokens=* delims=." %%b in (test.txt) do (if %%a==%%b (goto :next) else ( echo %%a)
)
: Next
echo out of inner loop
)
Anyone can help....?
Even if the goto label is in the for loop, it also goes out the loop context. Such as
This will print out A %d %f
you do not have to reinvent the wheel (if you have a choice). This is just one way. Download diffutils for windows and then you can just do
A goto :label always breaks all loops.
But you can put your inner loop in a separated function, then it could work.
One remark, breaking of FOR /L loops does not work as expected, the for-loop always count to the end, but if you break it, the execution of the inner code is stopped, but it could be really slow.
EDIT:
Proof of concept
Output