Topic "Automated download but skip existing files"

Author Message
JanneFiH

Guest


Hi,
I apologize if this topic has been added before, but I tried finding any other thread with the same problem as me, but failed.
I'm trying to connect through FTP and download an entire library, but skip already existing files. The problem is that it overwrites them instead.

Can anyone be so kind to point out the error I'm doing?

Code:
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="F:\log\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://user:password@ip:21/ -passive=0" ^
    "cd /Docs" ^
    "lcd Z:\Docs" ^
    "get *" ^
    "exit"

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

exit /b %WINSCP_RESULT%


Thank you in advance!

Janne
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26705
Location: Prague, Czechia
Use -neweronly switch of the get command:
https://winscp.net/eng/docs/scriptcommand_get#neweronly

Or use synchronize local command instead of get:
https://winscp.net/eng/docs/scriptcommand_synchronize
JanneFiH

Guest


martin wrote:
Use -neweronly switch of the get command:
https://winscp.net/eng/docs/scriptcommand_get#neweronly

Or use synchronize local command instead of get:
https://winscp.net/eng/docs/scriptcommand_synchronize


Thank you for your help, Martin.

I edited the script as:

"get * -neweronly" ^

And it works perfectly. Thanks again!

/Janne
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License