Backend / DevOps / Architect
Brit by birth,
located worldwide

All content © Alex Shepherd 2008-2024
unless otherwise noted

Grab a whole folder with wget

Published
1 min read
image
Image Credit: Unknown (if this is your work, reach out to me and I'll credit you!)

Hey folks,

When needing to download a whole folder with wget, I've always run into problems with the mirror option, which is what everybody points towards when somebody asks how to achieve this. It creates massive unnecessary directory structures, leaving actually what you want hidden somewhere within. I found a command today, which circumvents this nonsense, and just downloads the contents of the folder you point it at...

wget -nd -nH -r http://www.site.dir/name/goes/here

The -nd can also be entered as --no-directories in verbose form. This stops the command creating the folder hierarchy on your local machine.

The -nH (--no-host-directories) stops the command from creating a folder labelled with the domain name at the top of the hierarchy (in the example above - www.site.dir).

Works a charm!

n00b