使用WinSCP命令行获取远程目录上特定日期的内容列表

时间:2014-04-16 15:47:54

标签: c# ftp sftp winscp

目前我正在使用两个命令。

First =>这将列出特定路径上的所有文件:

CommandText += @"/command ""option batch abort"" ""option confirm off"" ""Open """"" + SFTPAddress;
CommandText += @""""" -passive=on"" ""Put """"" + SourcePath;
CommandText += @""""" """"" + TargetPath + @"""""";
CommandText += @""" ""ls """"" + TargetPath + @"""""";
CommandText += @""" ""close"" ""exit"" ";
CommandText += @"/xmllog=""" + logname + @"""";

秒=>这将列出特定文件的文件信息:

CommandText += @"/command ""option batch abort"" ""option confirm off"" ""Open """"" + SFTPAddress;
CommandText += @""""" -passive=on"" ""Put """"" + SourcePath;
CommandText += @""""" """"" + TargetPath + @"""""";
CommandText += @""" ""stat """"" + TargetPath + filename + @"""""";
CommandText += @""" ""close"" ""exit"" ";
CommandText += @"/xmllog=""" + logname + @"""";

我需要的是使用命令行列出使用文件信息在特定日期上传的所有文件。

1 个答案:

答案 0 :(得分:1)

自WinSCP 5.5.4起,您可以time-constraints使用ls命令:

ls "*>2014-11-14"

参考文献:
https://winscp.net/eng/docs/scriptcommand_ls
https://winscp.net/eng/docs/file_mask#size_time


或者,您可以切换到WinSCP .NET程序集:
https://winscp.net/eng/docs/library

请参阅Session.ListDirectory方法:
https://winscp.net/eng/docs/library_session_listdirectory

然后,您可以使用C#构造轻松过滤返回的集合。

看到类似的问题:
List files with specific extension using WinSCP .NET assembly

有关将当前脚本转换为WinSCP .NET汇编代码的详细信息,请参阅:
    https://winscp.net/eng/docs/library_from_script

相关问题