Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I download multiple files using wget? I also want to rename the files. Here are the commands I'm running one by one (copy/paste on terminal):

    wget -c --load-cookies cookies.txt http://www.filesonic.com/file/812720774/PS11.rar -O part11.rar
    wget -c --load-cookies cookies.txt http://www.filesonic.com/file/812721094/PS12.rar -O part12.rar
    wget -c --load-cookies cookies.txt http://www.filesonic.com/file/812720804/PS13.rar -O part13.rar
    wget -c --load-cookies cookies.txt http://www.filesonic.com/file/812720854/PS14.rar -O part14.rar
........ and so on..

What can I do to download all these files one by one?

share|improve this question
    
This is very similar to superuser.com/questions/336669/… – RedGrittyBrick Jan 3 '12 at 9:59

You probably want a short shell script like this:

#!/usr/bin/env bash
while read line
do
  wget -c --load-cookies cookies.txt $line -O ${line##*/}
done < filelist

Where filelist is a text file that contains each download link, one by one. ${line##*/} will extract the filename itself and therefore produce something similar to the following commands:

wget -c --load-cookies cookies.txt http://download/file1.rar -O file1.rar
wget -c --load-cookies cookies.txt http://download/file2.rar -O file2.rar
wget -c --load-cookies cookies.txt http://download/file3.rar -O file3.rar

If you want to run these in parallel, you can also just wrap the wget line inside parentheses to run it in a subshell.

(wget -c --load-cookies cookies.txt $line -O ${line##*/})

Or add an ampersand. This would however mean that the downloads will still run when you cancel the script. You'd have to kill them manually for each process.

wget -c --load-cookies cookies.txt $line -O ${line##*/} &
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .