@echo off :: Automatically resolve the project directory from the batch file location cd /d "%~dp0" :: Try up to 5 times (every 30 minutes = ~2.5 hours of retries) set RETRIES=5 :retry "%~dp0venv\Scripts\python.exe" "%~dp0scraper\news_scraper.py" if %ERRORLEVEL% EQU 0 ( echo Scraper ran successfully. exit /b 0 ) set /a RETRIES=%RETRIES%-1 if %RETRIES% GTR 0 ( echo Scraper failed. Retrying in 30 minutes... (%RETRIES% retries left) timeout /t 1800 /nobreak >nul goto retry ) echo All retries exhausted. exit /b 1