C:\batextra>type mon.bat
@echo off
FOR /L %%i IN (0,1,999999) DO (
echo %%i
if %%i==89 set var=%%i && goto eof
)
:eof
echo outside var=%var%
OUTPUT:
C:\batextra>mon.bat
.
.
.
76
77
78
79
80
81
82
83
84
85
86
87
88
89
outside var=89
C:\batextra>echo %var%
89
C:\batextra>
REM: The For loop variable, %%i, only contains one number at any one time. At the end of the loop %%i = %var% = 999999
After the loop works as you need it to, then add your other commands.
The numbers inside the for loop will always exist. The test for money folders will require more than a test of the for loop counter.