简体   繁体   English

批处理文件 - 下载最新的 FTP 文件夹

[英]Batch file - Download the latest FTP folder

I'm trying to download the latest folder from an FTP server.我正在尝试从 FTP 服务器下载最新的文件夹。 This folder contains several folders in which contains several CSV files.此文件夹包含多个文件夹,其中包含多个 CSV 文件。

The issue I have is that the folders are created each day and each time I run the script I only want it to download the latest folder at that location.我遇到的问题是每天都会创建文件夹,每次运行脚本时,我只希望它下载该位置的最新文件夹。

I have not the foggiest idea of how to specify this, or even download an entire folder structure from an FTP using batch file.我不知道如何指定这一点,甚至不知道如何使用批处理文件从 FTP 下载整个文件夹结构。

Please let me know if any additional information is required and I will provide it immediately, thanks again for your help.如果需要任何其他信息,请告诉我,我会立即提供,再次感谢您的帮助。

Kind Regards,亲切的问候,
Lewis刘易斯

There's no easy way to select the most recent folder with the built-in Windows FTP client, the ftp.exe .没有简单的方法可以使用内置的 Windows FTP 客户端ftp.exe选择最新的文件夹。 You would have more luck with a PowerShell script and the FtpWebRequest .使用 PowerShell 脚本和FtpWebRequest会更幸运。

But even if you manage to select the most recent directory, neither the ftp.exe nor the FtpWebRequest support recursive downloads anyway.但是即使您设法选择了最新的目录, ftp.exeFtpWebRequest都不支持递归下载。

You better use some more powerful 3rd party FTP client.你最好使用一些更强大的 3rd 方 FTP 客户端。


For example with WinSCP FTP client you can download the latest file or folder, using the -latest switch of the get command (WinSCP 5.9 and newer):例如,使用WinSCP FTP 客户端,您可以使用get命令(WinSCP 5.9 和更新版本)的-latest开关下载最新的文件或文件夹:

winscp.com /command ^
    "open ftp://username:password@ftp.example.com/" ^
    "cd /remote/path" ^
    "lcd c:\local\path" ^
    "get -latest *" ^
    "exit"

See also the guide to downloading the most recent file with WinSCP .另请参阅使用 WinSCP 下载最新文件的指南。

(I'm the author of WinSCP) (我是 WinSCP 的作者)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM