Как указать каталог, в который wget
следует загружать все файлы? Чтобы понять, что я сейчас запускаю скрипт:
wget -r --no-parent --reject "index.html*" http://water.weather.gov/precip/p_download_new/2010/01/01/
Проблема в том, что файлы хранятся в water.weather.gov/precip/p_download_new/2010/01/01/
, я хотел бы сохранить все файлы только в 2010/01/01
, как я могу указать это?
можно использовать его likfe это
wget -r --no-parent -P /path-to-"2010/01/01"-directory -nd --reject "index.html*" http://water.weather.gov/precip/p_download_new/2010/01/01/
Необходимо добавить -P /your/chosen/directory
к команде.
Добавьте параметр -P
:
wget -P "2010/01/01" -nd -r --no-parent --reject "index.html*" http://water.weather.gov/precip/p_download_new/2010/01/01/
И более универсальный. С этой версией выходная папка определяется автоматически:
URL="http://water.weather.gov/precip/p_download_new/2010/01/01/"; wget -P "$(awk -F'/' '{ print $(NF-3),$(NF-2),$(NF-1)}' OFS="/" <<<$URL)" -nd -r --no-parent --reject "index.html*" "$URL"
от man wget
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix.
The directory prefix is the directory where all other files and
subdirectories will be saved to, i.e. the top of the retrieval
tree. The default is . (the current directory).
-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).