如何使用WinSCP脚本从SFTP复制新文件

时间:2017-07-20 09:40:53

标签: sftp winscp

我想使用WinSCP从一个SFTP服务器下载新文件。

假设我今天在源和目的地都有10个文件 明天可以将一个新文件添加到源中。在这种情况下,我想将新文件仅复制到目标。

我正在使用以下脚本:

open sftp_connection
cd /path
option transfer binary
get "*.txt" localpath
close
exit

通过使用上面的内容,我可以复制所有文件,但我只想要目标中不可用的新文件。

谢谢,
Srikrishna。

1 个答案:

答案 0 :(得分:0)

最简单的解决方案是将-neweronly switch添加到get command

get -neweronly *.txt C:\local\path\*

对于非常相似的结果,您还可以使用synchronize command

synchronize local . C:\local\path -filemask=*.txt

另见Downloading the most recent file上的WinSCP文章。