automation downloading and uploading more recent file

Advertisement

Mahdi Bashiri
Joined:
Posts:
25

automation downloading and uploading more recent file

Dear
i'm using winscp script to downloading more recent file from remote ftp server to localdirectory and uploading more recent file from localdirectory to remote ftp server and want to use these scripts to keep up to date by using :

synchronize local D:\IscFtp\Report Report for downloading
synchronize remote D:\IscFtp\In In for uploading

i would like to know is there ant script to do keep up to date remote or local directory like in gui option or no. and use this script to running all time and monitoring and changes and do downloading or uploading.

Regards,
Mahdi Bashiri

Reply with quote

Advertisement

Jovy
Guest

Upload recent file from local server to the remote server

Hi,

I've tried the "-latest" command and it works fine although I need to upload files with a time duration (i.e. 24 hours). I've read that I could use "-filemask" but when I am executing .bat file, the script simply doesn't proceed. The cmd shows and closes immediately. Please help.

Script:
open sftp://sftpJSamar:username@host_ip/ -hostkey=""
lcd C:\Users\Jovy.Samar\Desktop
cd /home/ftp-files/SAC/MASTERS
put -filemask="*>=1D" C:\Users\Jovy.Samar\Desktop\* /home/ftp-files/SAC/MASTERS
exit

Batch file:
@echo on

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Users\Jovy.Samar\Desktop\log\WinSCP.log" /ini=nul ^
/command ^
"open sftp://sftpJSamar:username@host_ip/ -hostkey=""""" ^
"lcd C:\Users\Jovy.Samar\Desktop" ^
"cd /home/ftp-files/SAC/MASTERS" ^
"put -filemask="*>=1D" C:\Users\Jovy.Samar\Desktop\* /home/ftp-files/SAC/MASTERS" ^
"exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

exit /b %WINSCP_RESULT%

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,378
Location:
Prague, Czechia

Re: Upload recent file from local server to the remote server

Jovy wrote:

I've tried the "-latest" command and it works fine although I need to upload files with a time duration (i.e. 24 hours). I've read that I could use "-filemask" but when I am executing .bat file, the script simply doesn't proceed. The cmd shows and closes immediately. Please help.
So do you run the script or the batch file?
Your batch file has quotes wrong.
See
https://winscp.net/eng/docs/commandline#syntax
https://winscp.net/eng/docs/faq_batch_file#quotes

Reply with quote

Advertisement

You can post new topics in this forum