w10install/software/download-software.cmd

63 lines
1.3 KiB
Batchfile
Raw Normal View History

2021-02-21 15:43:09 +01:00
@echo off
2021-02-24 22:26:55 +01:00
rem ===================
rem COMMANDLINE CHECKS
rem ===================
IF %1.==. GOTO USAGE
rem removing extension ...
set LISTFILE=%~n1
rem adding extension again ...
set LISTFILE=%LISTFILE%.csv
2021-02-21 15:43:09 +01:00
IF NOT EXIST %LISTFILE% (
echo ERROR: %LISTFILE% not found!
exit /b
2021-02-22 18:36:22 +01:00
)
2021-02-21 15:43:09 +01:00
2021-03-08 22:38:04 +01:00
echo using list [ %LISTFILE% ] ...
2021-02-24 22:26:55 +01:00
2021-02-21 15:43:09 +01:00
rem ###################################
rem MAIN loop ( download software ) ...
rem ###################################
FOR /F "tokens=1,2 delims=, " %%E in (%LISTFILE%) do (
2021-02-21 17:29:18 +01:00
rem file is already present ?
IF %%~zF EQU 0 (
del /F %%F 2>nul
echo INFO: [ %%F ] does not exist or is 0 bytes, starting download ...
2021-02-21 15:43:09 +01:00
)
2021-02-21 17:29:18 +01:00
IF NOT EXIST %%F (
rem get it with curl ...
2021-02-22 18:36:22 +01:00
echo getting: %%F [ %%E ]
2021-02-21 17:29:18 +01:00
curl --connect-timeout 5 --fail-early -L %%E --output %%F
rem success ?
if NOT EXIST %%F (
echo ERROR: couldn't get %%F!
) ELSE (
rem check size (it SHOULD NOT be 0!)
FORFILES /M %%F /C "cmd /C if @fsize EQU 0 echo ERROR: file @relpath is zero size!"
)
) ELSE (
FORFILES /M %%F /C "cmd /C if @fsize NEQ 0 echo OK: file @relpath is [ @fsize ] bytes"
2021-02-21 15:43:09 +01:00
)
)
2021-02-24 22:26:55 +01:00
rem =====
rem END
rem =====
GOTO END
:USAGE
echo "usage: %0 <LISTFILE>"
2021-03-02 21:47:42 +01:00
echo LISTFILE = basic, browser or optional
2021-02-24 22:26:55 +01:00
echo.
:END