@echo off
set FTPSETTINGS=..\company\ftpsettings.cmd
set APPSFOLDER=storeapps

rem ===================
rem CONFIGFILE CHECK
rem ===================

if NOT EXIST %FTPSETTINGS% (
  echo.
  echo ERROR: %FTPSETTINGS% NOT FOUND
  echo.
  echo --- please create it as follows ---
  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
)

echo.
echo loading settings ...
call %FTPSETTINGS%
echo ++++++++++++++++++
echo FTP_SERVER=%FTP_SERVER%
echo FTP_PATH=%FTP_PATH%
echo FTP_USER=%FTP_USER%
echo FTP_PASS=xxxxxx
echo ++++++++++++++++++
echo.

rem #####################################
rem MAIN loop ( UPLOAD apps to ftp ) ...
rem #####################################

rem folder present ?
IF EXIST %APPSFOLDER% (
  rem UPLOAD with curl ...
  FOR %%F in (%APPSFOLDER%\*.*) DO (
    echo processing ... [ %%F ]
    curl -u %FTP_USER%:%FTP_PASS% -T %%F ftp://%FTP_SERVER%/%FTP_PATH%/%APPSFOLDER%/
  )
) else (
  echo WARNING: [ %APPSFOLDER% ] does not exist, cannot upload ...
)

