@echo off
REM Batch file to run URLNotesGrabberCORE 500 times in a loop

setlocal enabledelayedexpansion

REM Set the path to the executable
REM Update this path if your executable is in a different location
set APP_PATH=URLNotesGrabberCORE.exe

REM Check if the executable exists
if not exist "%APP_PATH%" (
    echo Error: %APP_PATH% not found in the current directory.
    echo Please ensure the executable is in the same directory as this batch file,
    echo or update the APP_PATH variable with the correct path.
    pause
    exit /b 1
)

REM Loop counter
set ITERATIONS=500
set COUNTER=0

echo Starting to run %APP_PATH% %ITERATIONS% times...
echo.

:LOOP
set /a COUNTER+=1
echo [%COUNTER%/%ITERATIONS%] Running iteration %COUNTER%...
echo Started at: %date% %time%

REM Run the application with -replies option
call "%APP_PATH%" -replies

REM Check if the application ran successfully
if errorlevel 1 (
    echo Warning: Application exited with error code !ERRORLEVEL! on iteration %COUNTER%
) else (
    echo Iteration %COUNTER% completed successfully.
)

echo Completed at: %date% %time%
echo.

REM Check if we've reached 500 iterations
if %COUNTER% lss %ITERATIONS% (
    goto LOOP
)

echo.
echo Completed all %ITERATIONS% iterations!
echo.
pause
