@ECHO off set CALL_DIR=%CD% set HUB=%1 set ANALYSIS_ID=%2 set SAVEDIR=%3 set ANALYSIS_CSV_URL="%HUB%/analysis/%ANALYSIS_ID%.csv" set CURL_CMD=curl if not exist "%SAVEDIR%" mkdir %SAVEDIR% cd /D %SAVEDIR% rm -fr * %CURL_CMD% %ANALYSIS_CSV_URL% -o warnings.csv for /F "skip=1 tokens=*" %%L in (warnings.csv) do call :handle_csv_line "%%L" cd /D %CALL_DIR% exit /b :handle_csv_line set LINE=%1 REM obtain URL component from last column of line set LASTCOLUMN= set /A COUNTER=0 :LOOP1BEGIN set /A COUNTER+=1 for /F "tokens=%COUNTER% delims=," %%A in (%LINE%) do ( if "%%A"=="" goto :LOOP1END set LASTCOLUMN=%%A goto :LOOP1BEGIN) :LOOP1END REM use URL component to compute URL and basename set url2="%LASTCOLUMN:~0,-4%.html" set /A COUNTER=0 :LOOP2BEGIN set /A COUNTER+=1 for /F "tokens=%COUNTER% delims=/" %%A in ("%url2%") do ( if "%%A"=="" goto :LOOP2END set basename=%%A goto :LOOP2BEGIN) :LOOP2END REM download the page %CURL_CMD% %HUB%%url2% -o %basename% exit /b