I have a TXT file containing a list of URLs like:
website/media/945746/ui4Q9EJoUEmVLtUNhtRX.JPG John.JPG
website/media/226251/6epk0CUwnhofAjZMP2xp.JPG Kelly.JPG
website/media/658552/Q4qQgLF2bvVwxI37jgQG.JPG Sharon.JPG
website/media/856214/8xlBzvlG4TNfKgo86gM6.JPG Bill.JPG
I am using xargs -n 1 curl -O < urls.txt
to download the images.
How do I download the file so ui4Q9EJoUEmVLtUNhtRX.JPG
is renamed as John.JPG
, 6epk0CUwnhofAjZMP2xp.JPG
is renamed as Kelly.JPG
etc.
Just reverse the order of two fields:
while read -r url name ; do
curl -o $name $url
done < urls.txt
If you want concurrent download, let every curl command run in background and wait
for them to finish.
PS: -O
means output file name for wget
not curl
. curl
uses -o
instead.