如何使用 FTP 将所有 .html 文件上传到远程服务器并保留文件结构?
我在本地编辑了大约 100 个 html 文件,现在我想将它们推送到我的实时服务器,我只能通过 ftp 访问该服务器。
HTML 文件位于许多不同的目录中,但远程计算机上的目录结构与本地计算机上的相同。
如何从顶级目录递归地将所有 .html 文件下载到远程计算机上相应的目录/文件名?
谢谢!
I have edited about 100 html files locally, and now I want to push them to my live server, which I can only access via ftp.
The HTML files are in many different directories, but hte directory structure on the remote machine is the same as on the local machine.
How can I recursively descend from my top-level directory ftp-ing all of the .html files to the corresponding directory/filename on the remote machine?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您想在Python中执行此操作(而不是使用其他预先打包的现有工具),您可以使用 os.walk 读取本地子树中的所有内容,并且 ftplib 执行所有 FTP 操作。特别是, storbinary 是您的方法通常会用于传输整个文件而不进行行结束转换(storlines,如果您确实需要行结束转换,对于文本文件,而不是二进制文件,并且您知道需要这样的处理)。
If you want to do it in Python (rather than using other pre-packaged existing tools), you can use os.walk to read everything in the local subtree, and ftplib to perform all the FTP operations. In particular, storbinary is the method you'll usually use to transfer entire files without line-end conversions (storlines if you do want line-end conversions, for files that are text, not binary, and that you know need such treatment).
嗯,也许在 Linux 的 mc 或 Windows 的 Total Commander 中按 F5?
umm, maybe by pressing F5 in mc for linux or total commander for windows?
搜索PyPI后,我找到了ftptool(http://pypi.python.org/pypi/ ftptool/0.4.2)。它的
mirror_to_remote
方法可能正是您所需要的。不过,我手边没有 FTP 服务器,所以无法测试它。After searching PyPI, I found ftptool (http://pypi.python.org/pypi/ftptool/0.4.2). Its
mirror_to_remote
method could be what you need. I don't have an FTP server handy, though, so I couldn't test it.如果你有 Mac,你可以尝试 cyberduck。它非常适合通过 ftp 同步远程目录结构。
if you have a mac, you can try cyberduck. It's good for syncing remote directory structures via ftp.