如何使用 wget 镜像目录而不创建父目录?
我想通过 FTP 镜像一个文件夹,如下所示:
wget --mirror --user=x --password=x ftp://ftp.site.com/folder/subfolder/evendeeper
但我不想创建如下目录结构:
ftp.site.com ->文件夹->子文件夹->甚至更深
我只是想要:
更深
及其以下的任何内容都是最终的结构。只要在服务器上为 evendeeper
的子目录创建子目录,evendeeper
的内容出现在当前目录中也是可以接受的。
我知道 -np
选项,根据文档,它只是阻止它跟踪到父页面的链接(对于我通过 FTP 镜像的二进制文件来说这不是问题)。我还知道 -nd
选项,但这根本无法创建任何目录结构,即使对于 evendeeper
的子目录也是如此。
我会考虑替代方案,只要它们是基于命令行的,可以作为 Ubuntu 软件包随时使用,并且可以像 wget 一样轻松自动化。
I want to mirror a folder via FTP, like this:
wget --mirror --user=x --password=x ftp://ftp.site.com/folder/subfolder/evendeeper
But I do not want to create a directory structure like this:
ftp.site.com -> folder -> subfolder -> evendeeper
I just want:
evendeeper
And anything below it to be the resulting structure. It would also be acceptable for the contents of evendeeper
to wind up in the current directory as long as subdirectories are created for subdirectories of evendeeper
on the server.
I am aware of the -np
option, according to the documentation that just keeps it from following links to parent pages (a non-issue for the binary files I'm mirroring via FTP). I am also aware of the -nd
option, but this prevents creating any directory structure at all, even for subdirectories of evendeeper
.
I would consider alternatives as long as they are command-line-based, readily available as Ubuntu packages and easily automated like wget.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于如下路径:
ftp.site.com/a/b/c/d
-nH
会将所有文件下载到目录a/b/c/ d
在当前目录中,-nH --cut-dirs=3
会将所有文件下载到当前目录中的d
目录中。For a path like:
ftp.site.com/a/b/c/d
-nH
would download all files to the directorya/b/c/d
in the current directory, and-nH --cut-dirs=3
would download all files to the directoryd
in the current directory.我有类似的要求,以下组合似乎是完美的选择:
在下面的示例中, http:// 中的所有文件url/dir1/dir2 (单独)被下载到本地目录 /dest/dir
感谢 @ffledgling 有关“-nd”的提示
对于上面的示例:
来自手册的片段:
I had a similar requirement and the following combination seems to be the perfect choice:
In the below example, all the files in http://url/dir1/dir2 (alone) are downloaded to local directory /dest/dir
Thanks @ffledgling for the hint on "-nd"
For the above example:
Snippets from manual:
-np
(无父)选项可能会做你想要的,与-L 1
结合在一起(我认为,在我之前没有安装 wget),这将递归限制为一级。编辑。好的。啊...也许我应该等到我喝完咖啡...有一个
--cut
或类似的选项,它允许您从输出路径“剪切”指定数量的目录,因此,对于/a/b/c/d
,削减 2 将强制 wget 在本地计算机上创建c/d
-np
(no parent) option will probably do what you want, tied in with-L 1
(I think, don't have a wget install before me), which limits the recursion to one level.EDIT. ok. gah... maybe I should wait until I've had coffee.. There is a
--cut
or similar option, which allows you to "cut" a specified number of directories from the output path, so for/a/b/c/d
, a cut of 2 would force wget to createc/d
on your local machine而不是使用:
使用:
这将剪切更多目录并且不会创建任何文件夹。
注意:100 = 要跳过创建的文件夹数量。
您可以将 100 更改为任何数字。
Instead of using:
use:
This will cut more directories and no folders will be created.
Note: 100 = the number of folders to skip creating.
You can change 100 to any number.