Copy ONLY New Files from Remote Server to Local Server without checking the Timestamp

Advertisement

ehutchin
Joined:
Posts:
1
Location:
California

Copy ONLY New Files from Remote Server to Local Server without checking the Timestamp

I hope someone can help with this. Using batch scripting with WinSCP, I am trying to copy ONLY NEW FILES from a remote SFTP server to my local server.

The problem I am having is the timestamp changes on files on the remote server on All files <=5 days. (Their process will not change)

So I get a combination of new files and files that already existed on my local drive, but just have a different timestamp.

I would like to copy ONLY files that are New and doesn't exist in MyLocalFolder when compared to TheirRemoteFolder.

I've tried the WinSCP synchronize command, but that seems to have 2 criteria of (1) New Files and (2) Files with newer timestamps. I want to exclude copying files based on the timestamp since the remote location keep changing the timestamp of their files.

The script command I ran is the following:
option batch abort
option confirm off
open sftp://ServerConnectInfo/ -hostkey="PasswordKeyStuff"
synchronize local "C:\MyLocalFolder" "/TheirRemoteFolder"
exit
With that script, I get new files, but I also get files that I already have because the modified or created timestamp differs.
Can anyone suggest code within the WinSCP scripting that can copy ONLY the new files where?

I'm not trying to use any other code to do this, as that would bring in other issues. Just trying to complete this using just a batch file and a WinSCP scripting text file.

Reply with quote

Advertisement

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

Re: Copy ONLY New Files from Remote Server to Local Server without checking the Timestamp

If you want to transfer only files that do not exist in the destination directory, and ignore changes to existing files, use:
synchronize local -criteria=none "C:\MyLocalFolder" "/TheirRemoteFolder"
https://winscp.net/eng/docs/scriptcommand_synchronize#criteria
https://winscp.net/eng/docs/ui_synchronize#criteria

Reply with quote

Advertisement

You can post new topics in this forum