w10install/software/upload-to-ftp.cmd

79 lines
1.5 KiB
Batchfile
Raw Permalink Normal View History

2021-03-08 22:38:04 +01:00
@echo off
2024-02-23 14:03:56 +01:00
set FTPSETTINGS=..\custom\ftpsettings.cmd
2021-03-08 22:38:04 +01:00
rem ===================
rem CONFIGFILE CHECK
rem ===================
2021-03-13 23:32:05 +01:00
if NOT EXIST %FTPSETTINGS% (
2021-03-08 22:38:04 +01:00
echo.
2021-03-13 23:32:05 +01:00
echo ERROR: %FTPSETTINGS% NOT FOUND
2021-03-08 22:38:04 +01:00
echo.
2021-03-13 00:30:15 +01:00
echo --- please create it as follows ---
2021-03-08 22:38:04 +01:00
echo set FTP_SERVER=example.com
echo set FTP_PATH=/path/to/directory
echo set FTP_USER=myuser
echo set FTP_PASS=mypass
exit /b
)
rem ===================
rem COMMANDLINE CHECKS
rem ===================
IF %1.==. GOTO USAGE
rem removing extension ...
set LISTFILE=%~n1
rem adding extension again ...
set LISTFILE=%LISTFILE%.csv
IF NOT EXIST %LISTFILE% (
echo ERROR: %LISTFILE% not found!
exit /b
)
echo.
echo loading settings ...
2021-03-13 23:32:05 +01:00
call %FTPSETTINGS%
2021-03-08 22:38:04 +01:00
echo ++++++++++++++++++
echo FTP_SERVER=%FTP_SERVER%
echo FTP_PATH=%FTP_PATH%
echo FTP_USER=%FTP_USER%
echo FTP_PASS=xxxxxx
echo ++++++++++++++++++
echo.
echo using list [ %LISTFILE% ] ...
rem ###################################
2021-03-11 22:16:10 +01:00
rem MAIN loop ( UPLOAD to ftp ) ...
2021-03-08 22:38:04 +01:00
rem ###################################
FOR /F "tokens=1,2 delims=, " %%E in (%LISTFILE%) do (
rem file present ?
IF EXIST %%F (
rem UPLOAD with curl ...
echo.
echo upload of: [ %%F ]
curl -u %FTP_USER%:%FTP_PASS% -T %%F ftp://%FTP_SERVER%/%FTP_PATH%/
) else (
echo.
echo WARNING: [ %%F ] does not exist, cannot upload ...
)
)
rem =====
rem END
rem =====
GOTO END
:USAGE
echo "usage: %0 <LISTFILE>"
echo LISTFILE = basic, browser, optional or other
echo.
:END
2023-01-01 15:16:29 +01:00