cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Download multiple files from ftp

From: Lubomir Brindza <lubomir.brindza_at_gmail.com>
Date: Fri, 04 Oct 2013 08:57:06 +0200

> The problem is that the file on ftp site changes name everyday.
> For example, the file name is ce2013-10-03-10.14.02.sql.gz and everyday the final part of the file changes.
> Since curl does not accept wildcards, how can I download my file without editing my batch file everyday?
>
> In addition, I need to save that file in a specific directory, but my guess is that I can simply use:
> -o "F:\Backup\website-db\

Hi. You can use number sequences in cURL URLs, like this (shamelessly
stolen from the manpage):

    ftp://ftp.numericals.com/file[1-100].txt
    ftp://ftp.numericals.com/file[001-100].txt (with leading zeros)
    ftp://ftp.letters.com/file[a-z].txt

...and while specifying the output filename, use "#1" to substitute the
actual value cURL found the file at, so in your example:

ftp://.../ce2013-10-03-[00-23].[00-59].[00-59].sql.gz -o
F:\Backup\website-db\ce2013-10-03-#1.#2.#3.sql.gz

Of course, this will produce quite the number of possible combinations,
so the more you can narrow the range down, the better.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-04