Using sync to download new files only

Advertisement

pc99
Joined:
Posts:
1

Using sync to download new files only

Hi all

What I'm trying to do is have winscp.com as a scheduled task regularly retrieve files (including subfolders) from remote /media/folder and place them in local c:\download. I'm using this (which seems to do the job very well):

winscp.com /command "option batch abort" "open sftp://user:pass@site" "synchronize local -criteria=size -preservetime -transfer=automatic -resumesupport=on C:\download /media/folder" "close" "exit"

The problem is that I then have another program monitoring c:\download which moves files and folders received based on certain criteria. The problem, of course, is that when winscp.com runs the next time, it sees that the files are missing, and downloads them again - when all I want are the new files it hasn't seen before. Any suggestions about how to get around this? I was thinking there might be a way for windows task scheduler or winscp to store its last run time in an environment variable or in a file or something, and then add something like -filemask=>%LASTRUNTIME% to the above command so that it only grabs files in /media/folder newer than the last run date... but I can't work out how to do that.

Any suggestions?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

Re: Using sync to download new files only

As you have already realized, you have to create the synchronization script dynamically with the file mask with time constraint.

What you can do is dynamically generate the script for the next run as the end of the synchronization using the current timestamp.

See also
https://winscp.net/eng/docs/faq_script_modified_files#no_old_files
https://winscp.net/eng/docs/script_download_timestamped_filename#scripting

Reply with quote

Advertisement

You can post new topics in this forum