I am trying to only download files that are created today, just like tomorrow I would only want to download files created tomorrow only. Essentially I log into the remote server with my script and download all the files right now with synchronize local
. What I want to do is just only download the files created today. Right now I just added the filemask and I am still getting all of the files however I only want today's files.
open sftp://location.net -passphrase="passphrase" -hostkey="key"
synchronize local C:\Users\localdrive\Desktop\test2 /Home/remoteFolder/
exit
I also tried
get /Home/remoteFolder/ -filemask=*>1D
and it hasn't changed anything.
Any suggestions would be great.
Use a file mask with a time constraint and the today
keyword to create the today's constraint.
get -filemask=">=today" /remote/path/* C:\local\path\
The today
keyword is supported by WinSCP 5.15 and newer only. In older versions, you can use %TIMESTAMP%
syntax:
get -filemask=">=%TIMESTAMP#yyyy-mm-dd%" /remote/path/* C:\local\path\
Your *>1D
file mask downloads files created/modified in the last 24 hours, so not only today's files.
Further reading:
- Question WinSCP time based file download;
- WinSCP article on Downloading the most recent file.
来源:https://stackoverflow.com/questions/49414527/downloading-files-with-todays-date-only-from-sftp-server-with-winscp