批处理文件 - 下载最新的FTP文件夹 [英] Batch file - Download the latest FTP folder

查看:227
本文介绍了批处理文件 - 下载最新的FTP文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从FTP服务器上下载最新的文件夹。该文件夹包含几个文件夹,其中包含多个CSV文件。



我遇到的问题是每天创建文件夹,每次运行脚本时我只希望它下载最新的文件夹。



我不知道如何指定它,甚至可以使用批处理文件从FTP下载整个文件夹结构。



请让我知道是否需要任何其他信息,我会立即提供,再次感谢您的帮助。

亲切的问候,

Lewis

解决方案

使用内置Windows FTP客户端选择最近的文件夹并不容易, Ftp.exe的。使用PowerShell脚本和 FtpWebRequest



但即使您设法选择最近的目录, ftp.exe 也没有 FtpWebRequest 支持递归下载。



你最好使用一些更强大的第三方FTP客户端。






例如 WinSCP FTP客户端您可以使用 -latest 开关下载最新的文件或文件夹。 /winscp.net/eng/docs/scriptcommand_getrel =nofollow> get 命令(WinSCP 5.9及更新版本):

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

另请参阅用WinSCP下载最新的文件



(我是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文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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