Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I download and set the filenames using wget -i?

I wanted to know how to define the input file for wget, in order to download several files and set a custom name for them, using wget -i filename

Analog example using -O

wget -O customname url
like image 634
davoclavo Avatar asked Apr 01 '12 00:04

davoclavo


1 Answers

-O filename works only when you give it a single URL.
With multiple URLs, all downloaded content ends up in filename.

You can use a while...loop:

cat urls.txt | while read url
do
    wget "$url" -O "${url##*/}"  # <-- use custom name here
done
like image 182
kev Avatar answered Sep 28 '22 06:09

kev