https://stackoverflow.com/questions/3942265/errorlevel-in-a-for-loop-batch-windows
Solution:
Add
setlocal EnableDelayedExpansion
to the start of your script, then use !errorlevel!
instead of %errorlevel%
https://ss64.com/nt/delayedexpansion.html
%variabale_name% 은 batch file 이 parsing 될 때 1회 결정되는 값인데 반해,
!variable_name! 는 해당 line 의 실행 시점에 값이 결정되어 그 line 이 실행될 때 마다 변경된다.