1

I would like to mirror an HTTP directory into a local folder with wget. I've tried a number of methods online which all seem to not be working. My test site is the Ubuntu repositories (http://archive.ubuntu.com/ubuntu/project/) folder. I've tried them 5 times only to have to cancel wget because it tried to download the entire domain instead of the projects folder. When I finally got it to mirror the actual folder, it locally nested it in the site's parent folders but didn't download the contents of the parent folders themselves.

What I'm wanting using cp (not possible): cp http://archive.ubuntu.com/ubuntu/project/ ~/project/

1

There is a way to have wget download recursively the way I think you want:

wget -r --no-parent -nH --cut-dirs=1 --reject "index.html*" http://archive.ubuntu.com/ubuntu/project/

The -nH --cut-dirs=1 flag gets rid of the directory structure.

This will recursively download or basically cp -r the project folder from the website to a new directory named ~/project.

Total of 2 directories and 11 files downloaded.

source

  • It's still nesting the project folder inside its parent directories. – KI4JGT Nov 24 '15 at 6:36
  • @KI4JGT got it, you need the flag -nH --cut-dirs=1 I have updated the answer. – mchid Nov 24 '15 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.