问题描述
我试图从FTP服务器上下载最新的文件夹。该文件夹包含几个文件夹,其中包含多个CSV文件。
我遇到的问题是每天创建文件夹,每次运行脚本时我只希望它下载最新的文件夹。
我不知道如何指定它,甚至可以使用批处理文件从FTP下载整个文件夹结构。
请让我知道是否需要任何其他信息,我会立即提供,再次感谢您的帮助。
亲切的问候,
Lewis
使用内置Windows FTP客户端选择最近的文件夹并不容易, Ftp.exe的
。使用PowerShell脚本和。
但即使您设法选择最近的目录, ftp.exe
也没有 FtpWebRequest
支持递归下载。
你最好使用一些更强大的第三方FTP客户端。
例如您可以使用(WinSCP 5.9及更新版本):
winscp.com / command ^
open ftp:// username:password@ftp.example.com/^
cd / remote / path^
lcd c:\ local \ path^
get -latest *^
exit
另请参阅。
(我是WinSCP的作者)
I'm trying to download the latest folder from an FTP server. This folder contains several folders in which contains several CSV files.
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.
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
. You would have more luck with a PowerShell script and the FtpWebRequest
.
But even if you manage to select the most recent directory, neither the ftp.exe
nor the FtpWebRequest
support recursive downloads anyway.
You better use some more powerful 3rd party FTP client.
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.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.
(I'm the author of WinSCP)
这篇关于批处理文件 - 下载最新的FTP文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!