【问题标题】:Get the list of content of specific date on remote directory using WinSCP command line使用 WinSCP 命令行获取远程目录上特定日期的内容列表
【发布时间】:2014-04-16 15:47:54
【问题描述】:

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

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 + @"""";

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

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 + @"""";

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

【问题讨论】:

    标签: c# ftp sftp winscp


    【解决方案1】:

    从 WinSCP 5.5.4 开始,您可以使用 time-constraintsls 命令:

    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

    【讨论】:

      猜你喜欢
      • 2016-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 2010-12-04
      • 2016-01-20
      • 2021-10-21
      • 1970-01-01
      相关资源
      最近更新 更多