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

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

问题描述

我正在尝试从 FTP 服务器下载最新的文件夹.此文件夹包含多个文件夹,其中包含多个 CSV 文件.

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.

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

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

推荐答案

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

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.

但即使您设法选择了最近的目录,ftp.exeFtpWebRequest 都不支持递归下载.

But even if you manage to select the most recent directory, neither the ftp.exe nor the FtpWebRequest support recursive downloads anyway.

你最好使用一些更强大的 3rd 方 FTP 客户端.

You better use some more powerful 3rd party FTP client.

例如使用 WinSCP FTP 客户端,您可以使用 -latest 下载最新的文件或文件夹get 命令 开关(WinSCP 5.9 和较新):

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:localpath" ^
    "get -latest *" ^
    "exit"

另请参阅使用 WinSCP 下载最新文件的指南.

(我是 WinSCP 的作者)

这篇关于批处理文件 - 下载最新的 FTP 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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