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?

  • 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
       ftp://wuarchive.wustl.edu/ls-lR.gz, 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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