Marcin Zaremba
Marcin Zaremba

Reputation: 253

curl - download only exists multiple files from commandline

How download only exists files with curl via commandline? I have code like this:

curl http://host.com/photos/IMG_4[200-950].jpg -u user:pass -o IMG_4#1.jpg

This command download all images from IMG_4200.jpg to IMG_4950.jpg - even if they do not exist.

Upvotes: 0

Views: 934

Answers (1)

Daniel Stenberg
Daniel Stenberg

Reputation: 58004

use -f

(HTTP) Fail silently (no output at all) on server errors. This is mostly done to better enable scripts etc to better deal with failed attempts. In normal cases when a HTTP server fails to deliver a document, it returns an HTML document stating so (which often also describes why and more). This flag will prevent curl from outputting that and return error 22.

This method is not fail-safe and there are occasions where non-successful response codes will slip through, especially when authentication is involved (response codes 401 and 407).

Upvotes: 2

Related Questions