Skip to content

Instantly share code, notes, and snippets.

@thexmeta
Forked from juyal-ahmed/readme.md
Created April 26, 2024 15:19
Show Gist options
  • Save thexmeta/c32570645f7afd9e5724eb75c6163eda to your computer and use it in GitHub Desktop.
Save thexmeta/c32570645f7afd9e5724eb75c6163eda 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