Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A directory listings enabled folder has 2 zip files. I am trying to download only one of them (the latest). Problem is the zip file name is a random string.

The command I have so far is

wget -r -nH --cut-dirs=3 --no-parent --accept=zip$name/?C=M;O=A

This seems to download all the zip files. I wish to download the first one wget will hit. Is there a way to do this?

share|improve this question
Does the one you don't want have a consistent name you can exclude? – Zoredache Apr 3 '14 at 15:18
@Zoredache Nope, they are both random strings – user3227965 Apr 3 '14 at 15:20

If the size of the zipfiles is significantly larger than the rest of the data, you could set --quota=max size of the smallest zipfile, note that wget won't stop downloading if the quota is exceeded while downloading a file:

   -Q quota
       Specify download quota for automatic
       retrievals.  The value can be specified in
       bytes (default), kilobytes (with k suffix),
       or megabytes (with m suffix).

       Note that quota will never affect downloading
       a single file.  So if you specify wget -Q10k, all of
       the ls-lR.gz will be downloaded.  The same
       goes even when several URLs are specified on
       the command-line.  However, quota is
       respected when retrieving either recursively,
       or from an input file.  Thus you may safely
       type wget -Q2m -i sites---download will be
       aborted when the quota is exceeded.

       Setting quota to 0 or to inf unlimits the
       download quota.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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