Skip to content

Instantly share code, notes, and snippets.

@tojibon
Last active April 17, 2018 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tojibon/f27cdc45b977267df2a132e4b5b0ec84 to your computer and use it in GitHub Desktop.
Save tojibon/f27cdc45b977267df2a132e4b5b0ec84 to your computer and use it in GitHub Desktop.
Downloading HTTP directory with all files and sub-directories
wget -r -N -np -nH --cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/

Explanation:

  1. It will download all files and subfolders in ddd directory:
  2. recursively (-r),
  3. not going to upper directories, like ccc/… (-np),
  4. not saving files to hostname folder (-nH),
  5. but to ddd by omitting first 3 folders aaa, bbb, ccc (--cut-dirs=3)
  6. excluding index.html files (-R index.html)
  7. Omitting download if file already exists

Reference:
http://bmwieczorek.wordpress.com/2008/10/01/wget-recursively-download-all-files-from-certain-directory-listed-by-apache/
https://stackoverflow.com/questions/23446635/how-to-download-http-directory-with-all-files-and-sub-directories-as-they-appear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment