sura2k
sura2k

Reputation: 7517

wget - Download a sub directory

How do I download only a sub directory using wget? Can I specify the subdirectory that I need to download?

Thanks!

Upvotes: 52

Views: 67720

Answers (3)

Karimai
Karimai

Reputation: 422

$ wget -m -p -E -k -K -np {URL Address}

You can use the man page for details of options.

NOTE: with the previous options, index of files will be download!

  • -m: options suitable for mirroring such as infinite recursion and timestamps
  • -p: page-requisites
  • -E: adjust extension
  • -k: convert links for local viewing
  • -K: backup original, don't clobber
  • -np: No parent

Upvotes: 21

Hervey Allen
Hervey Allen

Reputation: 41

Good information I was able to use. I tried:

wget -r -l1 --no-parent http://www.domain.com/subdirectory/

on a site that included multiple files of the form name.subname.subname2.etc.htm or .html. In order to pick these up I ran:

wget -r --no-parent http://www.domain.com/subdirectory/

and this worked fine.

Upvotes: 4

Aamir
Aamir

Reputation: 5440

You can do:

wget -r -l1 --no-parent http://www.domain.com/subdirectory/

where:

-r: recursive retrieving
-l1: sets the maximum recursion depth to be 1
--no-parent: does not ascend to the parent; only downloads from the specified subdirectory and downwards hierarchy

Upvotes: 87

Related Questions