Предположим каталог
http://www.example.com/content/media/images/vacation_photos
содержит ссылки на многие подкаталоги:
/sweden
/egypt
/canada
каждый из которых содержит набор JPEGs, и я хочу загрузить их всех на свою локальную папку:
/home/jack/VacationPhotos
Так, чтобы я закончил со всем в каталогах
/home/jack/VacationPhotos/sweden
/home/jack/VacationPhotos/egypt
/home/jack/VacationPhotos/canada
проблема, если я даю wget, что URL, подайте заявку -r
(рекурсивная) опция и -P /home/jack/VacationPhotos
опция, это загружает все на
/home/jack/VacationPhotos/content/media/images/vacation_photos/sweden
и так далее, а не структура я хотел. Действительно ли возможно получить этот вид поведения в wget?
Посмотрите -nH
и --cut-dirs
опция в wget
. Из страницы справочника:
--cut-dirs=number
Ignore number directory components. This is useful for getting a fine-grained control over the directory where recursive retrieval will be saved.
Take, for example, the directory at ftp://ftp.xemacs.org/pub/xemacs/. If you retrieve it with -r, it will be saved locally under ftp.xemacs.org/pub/xemacs/. While the -nH option can
remove the ftp.xemacs.org/ part, you are still stuck with pub/xemacs. This is where --cut-dirs comes in handy; it makes Wget not "see" number remote directory components. Here are
several examples of how --cut-dirs option works.
No options -> ftp.xemacs.org/pub/xemacs/
-nH -> pub/xemacs/
-nH --cut-dirs=1 -> xemacs/
-nH --cut-dirs=2 -> .
--cut-dirs=1 -> ftp.xemacs.org/xemacs/
...
If you just want to get rid of the directory structure, this option is similar to a combination of -nd and -P. However, unlike -nd, --cut-dirs does not lose with subdirectories---for
instance, with -nH --cut-dirs=1, a beta/ subdirectory will be placed to xemacs/beta, as one would expect.