Not really a question this one - but alternative answers are certainly welcome! :)

Sometimes I need to download files listed in an Apache directory listing, say as in:

... in a given directory on my computer, and I'd like to use command-line tools for that.

As far as wget is concerned, actually there are some switches that should be in place - noting that wget tends to either download single items - or to reconstruct the server folders locally!

As I just spent some half an hour figuring out what those proper switches are (to copy the remote files locally as through, say, FTP), I'd like to document them here; so the above link would be downloaded with:

wget -nd -r -l 1 http://www.gnu-darwin.org/www001/src/ports/net/samba-libsmbclient/work/samba-3.0.28/source/libsmb/

... where:

   -nd
   --no-directories
       Do not create a hierarchy of directories when retrieving
       recursively.  With this option turned on, all files will get saved
       to the current directory, without clobbering [...]

   -r
   --recursive
       Turn on recursive retrieving.

   -l depth
   --level=depth
       Specify recursion maximum depth level depth.  The default maximum
       depth is 5.

It would be nice to hear alternatives to the above command - maybe using different set of switches for wget - or maybe using curl or other packages...

link|improve this question

74% accept rate
feedback

1 Answer

See also -nH a.k.a --no-host-directories and --cut-dirs options. I also frequently use --accept/-A and --reject/-R.

link|improve this answer
Many thanks for these options, @jw013 - great to have a quick reference for them! Cheers! – sdaau Sep 19 '11 at 19:24
feedback

Your Answer

 
or
required, but never shown

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