Script to Push Files to Remote SFTP Server

# 1. Install WINSCP and include it in the %PATH% environmental variables
# 2. Run this script via Task Scheduler (run every minute)

echo off
option batch on
option confirm off
winscp.com /ini=nul /command ^
"open sftp://USERNAME:PASSWORD@remote.ftpserver.com:2222 -hostkey=""ssh-rsa 2048 xx:xx:03:6b:4f:09:4b:95:dc:0d:f1:xx:xx:xx:xx""" "lcd \\SERVER01\SOMETHING" "cd /REMOTE/DIRECTORY" "put -nopermissions -nopreservetime ""*.*""" "exit"
if %errorlevel% neq 0 exit /b %errorlevel%
del \\SERVER01\SOMETHING\*.* /Q

Leave a Reply

Your email address will not be published. Required fields are marked *