Upload multiple files to remote server SFTP

Advertisement

vish
Joined:
Posts:
2

Upload multiple files to remote server SFTP

Hi,

Need help on understanding how to send multiple files at some regular time interval.
I was referring to Using WinSCP scripting provided @ Uploading a list of files

Here I could not get what these files are and what are the contents?
script.tmp and list.txt

Example script from site
@echo off
set SESSION=sftp://user:password@example.com/
set REMOTE_PATH=/home/user/
 
echo open %SESSION% >> script.tmp
 
rem Generate "put" command for each line in list file
for /F %%i in (list.txt) do echo put "%%i" "%REMOTE_PATH%" >> script.tmp
 
echo exit >> script.tmp
 
winscp.com /script=script.tmp
set RESULT=%ERRORLEVEL%
 
del script.tmp
 
rem Propagating WinSCP exit code
exit /b %RESULT%
My script looks like this and needs a tweak to send multiple files at regular interval
@echo off
 
"D:\WinSCP3\WinSCP.com" ^
  /log="D:\WinSCP3\Logs\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://d111111:aaaa%%2A00@localhost:9222/ -hostkey=""ssh-ed25519 256 ce:b4:5d:24:94:6b:75:h0:87:57:4v:55:19:21:99:a1""" ^
    "lcd C:\Users\111111\Desktop" ^
    "cd /home/d111111" ^
    "put -neweronly -resumesupport=10 RemoteFileTransfer.xlsx" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%
Thanks in advance

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Upload multiple files to remote server SFTP

Sorry, but it's not clear what is your specific problem.
So you have a problem with scheduling or with selecting the files to transfer?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

The script.tmp is a temporary file generated by the batch file.
The list.txt contains list of file names.
Though I'm not sure that you need this. It looks like you just want to hard code the file names to the script.
WinSCP GUI can generate such a script file for you:
https://winscp.net/eng/docs/guide_automation#generating

For scheduling, see:
Schedule file transfers (or synchronization) to FTP/SFTP server

Reply with quote

Advertisement

You can post new topics in this forum