Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to download all the books from a URL list in bulk. The list is in a text file in http://ligman.me/W3TuLr. I'm trying to use wget on linux for this. All these URLs seem to be created using a URL shortening service. The problem is when I run wget --server-response --input-file=list.txt, the files are downloaded ok, but wget uses the shortened URL tag as their name, while I can see in server responses that the Location header for the direct file URL contains the real readable book name in it.

How can I get wget to write the output file in the readable file name? wget version is 1.13.4.

I'm open to any other linux comnands which can perform the same task.

share|improve this question
    
HAve you tried using curl instead? –  arielnmz Jul 13 at 5:39
    
curl acts the same and it does not even support urls list in a file. I had to use xargs. –  aalizadeh Jul 14 at 10:02

2 Answers 2

up vote 5 down vote accepted

Use the --trust-server-names option:

--trust-server-names: If this is set to on, on a redirect the last component of the redirection URL will be used as the local file name. By default it is used the last component in the original URL.

Note that in some cases this can be a security risk: you have no way of knowing what the created filename will be until you get it, and conceivably it could overwrite something you want. This used to be the default behaviour until that issue was discovered.

share|improve this answer
    
Thanks for the great answer. –  aalizadeh Jul 13 at 9:23

Have your tried the following

     $ wget -i downloadaddreslist.txt

where downloadaddresslist.txt is the file of the addresses?

share|improve this answer
1  
isn't -i option the same as --input-file which I have used? –  aalizadeh Jul 13 at 5:44

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.