Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.