Skip to content
Advertisement

Specify output names on multiple files with curl using ranges

I am trying to download a few hundred URL’s and specify the output name for each, the only difference is an ID in the URL, such as ..something/1/something.., ..something/3/something.., ..something/4/something.. etc.

I can use -o filename.zip but it will overwrite for each of the range of files, I am currently using:

curl -o file.zip http://example.com/something/[1-500]/something/example/foo/bar/comma/zip

How can I output as this:?

file1.zip, file3.zip, file4.zip, ..etc

Advertisement

Answer

A simple loop in your shell would do the trick e.g.:

#!/bin/bash
for i in `seq 1 500`; do
    curl -o file$i.zip http://example.com/something/$i/something/example/foo/bar/comma/zip
done
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement