仅使用 WinSCP 从 SFTP 服务器下载具有今天日期的文件

问题描述:

我试图只下载今天创建的文件,就像明天我只想下载明天创建的文件一样.基本上,我用我的脚本登录到远程服务器,并立即使用 synchronize local 下载所有文件.我想要做的只是下载今天创建的文件.现在我刚刚添加了文件掩码,我仍在获取所有文件,但是我只想要今天的文件.

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

我也试过

get /Home/remoteFolder/ -filemask=*>1D

它没有改变任何东西.

任何建议都会很棒.

使用 文件掩码时间限制today关键字创建今天的约束.

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\

today 关键字仅受 WinSCP 5.15 及更新版本支持.在旧版本中,您可以使用 %TIMESTAMP% 语法:

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\

您的 *>1D 文件掩码会下载过去 24 小时内创建/修改的文件,因此不仅限于今天的文件.


Your *>1D file mask downloads files created/modified in the last 24 hours, so not only today's files.

进一步阅读:

  • Question WinSCP time based file download;
  • WinSCP article on Downloading the most recent file.