将所有文件从一个FTP目录复制到另一个 [英] Copy all files from one FTP directory to another
问题描述
我必须将一个ftp目录内的所有现有文件复制到另一个服务器上的另一个ftp目录。我没有任何写脚本的经验 - 所以任何帮助都会很棒。
我想知道是否可以编写这个脚本,以便它每天都能发生在特定的时间?
我应该使用什么软件/语言? Python是一个非常知名的,但我想确保它符合我的要求。
有人可以给我一个基本的代码实现方法吗?
在此先感谢
最终,您最终可能会下载整个目录到本地机器并重新上传到另一个,因为通常无法在FTP中的目录之间复制文件。
请参阅 FTP将文件复制到另一个地方用相同的FTP 。
您将找到大量用于下载和上传的示例。你甚至不需要脚本语言。只需使用一些命令行FTP客户端。
例如,使用 WinSCP FTP客户端,您可以使用以下批处理文件( .bat
):
winscp.com /log=copy.log / command ^
open ftp:// username:password@ftp.example.com/^
get / source / remote / path / * C:\temporary\local\path\^
放到C:\\\\\\\\\\\\\\\\\路径/^
exit
请参阅自动向FTP服务器传输文件。
(我是WinSCP的作者)
I have to copy all existing files inside one ftp directory to another ftp directory on another server. I have not had any experience writing scripts - so any help with this would be great.
I'm wondering if its possible to write this script so that it happens every day at a specific time?
What software/ language should I use for this? Python is a well renowned one, but I want to make sure it suits my requirements.
Can someone give me a basic code implementation for how to do it?
Thanks in advance
In the end you will probably end up downloading the whole directory to a local machine and re-uploading it to the other, as there's generally no way to copy files between directories in FTP.
See FTP copy a file to another place in same FTP.
You will find plenty of examples for downloading and uploading. You do not even need a scripting language. Simply use some command-line FTP client.
For example with WinSCP FTP client, you can use the following batch file (.bat
):
winscp.com /log=copy.log /command ^
"open ftp://username:password@ftp.example.com/" ^
"get /source/remote/path/* C:\temporary\local\path\" ^
"put C:\temporary\local\path\* /destination/remote/path/" ^
"exit"
See the guide to Automating file transfers to and from FTP server.
(I'm the author of WinSCP)
这篇关于将所有文件从一个FTP目录复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!