WinSCP SFTP - 从文件夹上传最新修改的 CSV 文件 [英] WinSCP SFTP - Upload latest modified CSV file from folder

查看:62
本文介绍了WinSCP SFTP - 从文件夹上传最新修改的 CSV 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 机器上运行的 WinSCP(版本 5.9.5(内部版本 7441))中有以下脚本

I have the following script in WinSCP (version 5.9.5 (Build 7441)) running on a windows machine

# Establish the connection that was saved as MySFTPsite using GUI 
open MySFTPsite
synchronize remote -filemask="*.CSV" "K:\extract\" "/sftp_uploads/"

我通过批处理文件调用它.

I call this via a batch file.

这工作正常,只是它发送所有提取文件夹中的 .CSV 文件.

This works fine, except it sends ALL the .CSV files in the extract folder.

还有一个进程每小时将一个文件写入提取文件夹.

There is another process that writes a file ever hour into the extract folder.

我只想发送此提取文件夹中的 LATEST .CSV 文件.请问我该怎么做?

I want to send only the LATEST .CSV file in this extract folder. How can I do this please?

我上传到的远程服务器在处理文件后会删除文件..所以同步将始终一遍又一遍地发送所有文件.

The remote server that I upload to deletes the file once it processes the file.. so synchronize will always send all the files over and over again.

我不确定如何在脚本中格式化文件掩码或使用多个文件掩码(如果有这种情况甚至可能的话).

I'm not sure how to format the filemask in the script or use multiple filemasks (if there is such a thing or even possible).

我不想使用 PowerShell.

I do not want to use PowerShell.

我希望尽可能简单并使用我拥有的脚本.

I want to keep this as simple as possible and use the script that I have.

任何帮助将不胜感激.

推荐答案

使用 -put 命令的最新开关:

Use -latest switch of put command:

put -latest "K:\extract\*.csv" "/sftp_uploads/"

<小时>

虽然 -filemask="*.CSV>2H 可能对您有用,但如果不经常添加文件,一般来说这不是正确的解决方案.


While -filemask="*.CSV>2H may do for you, if the files are added infrequently, it's not the right solution in general.

有关所有可能性的讨论,请参阅关于上传最新文件的 WinSCP 文章.

For discussion about all possibilities, see WinSCP article on Uploading the most recent file.

这篇关于WinSCP SFTP - 从文件夹上传最新修改的 CSV 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆