Tom*_*ell 46 linux ftp wget mirror
我想通过FTP镜像文件夹,如下所示:
wget --mirror --user=x --password=x ftp://ftp.site.com/folder/subfolder/evendeeper
Run Code Online (Sandbox Code Playgroud)
但我不想创建这样的目录结构:
ftp.site.com - >文件夹 - >子文件夹 - >偶数
我只是想:
evendeeper
而它下面的任何东西都是最终的结构.evendeeper只要为evendeeper服务器上的子目录创建子目录,在当前目录中结束的内容也是可以接受的.
我知道这个-np选项,根据文档,它只是让它不跟随父页面的链接(我正在通过FTP镜像的二进制文件没有问题).我也知道这个-nd选项,但是这会阻止创建任何目录结构,即使对于子目录也是如此evendeeper.
我会考虑替代方案,只要它们是基于命令行的,随时可以作为Ubuntu软件包使用,并且像wget一样易于自动化.
小智 66
对于像这样的路径: ftp.site.com/a/b/c/d
-nH将所有文件下载到当前目录a/b/c/d中的目录,并将-nH --cut-dirs=3所有文件下载到当前目录d中的目录.
Mar*_*c B 10
-np(没有父级)选项可能会做你想要的,与之相关-L 1(我认为,在我之前没有安装wget),这会将递归限制在一个级别.
编辑.好.gah ...也许我应该等到我喝咖啡..有一个--cut或类似的选项,它允许你从输出路径"剪切"指定数量的目录,因此/a/b/c/d,减少2会强制wget c/d在本地计算机上创建
而不是使用:
-nH --cut-dirs=1
Run Code Online (Sandbox Code Playgroud)
使用:
-nH --cut-dirs=100
Run Code Online (Sandbox Code Playgroud)
这将删除更多目录,不会创建任何文件夹.
注意:100 =要跳过创建的文件夹数.您可以将100更改为任意数字.
我有类似的要求,以下组合似乎是完美的选择:
在下面的例子中,http://url/dir1/dir2(单独)中的所有文件都下载到本地目录/dest/dir
wget -nd -np -P /dest/dir --recursive http://url/dir1/dir2
Run Code Online (Sandbox Code Playgroud)
感谢@ffledgling 关于“-nd”的提示
对于上面的例子:
wget -nd -np --mirror --user=x --password=x ftp://ftp.site.com/folder/subfolder/evendeeper
Run Code Online (Sandbox Code Playgroud)
手册摘录:
-nd
--no-directories
Do not create a hierarchy of directories when retrieving recursively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the
filenames will get extensions .n).
-np
--no-parent
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.
Run Code Online (Sandbox Code Playgroud)