LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   wget input file and directory structure (https://www.linuxquestions.org/questions/linux-software-2/wget-input-file-and-directory-structure-725914/)

Eddie1506 05-14-2009 07:11 AM

wget input file and directory structure
 
Hi all,

I have a file with few hundred links to some files on a webpage.

I would like to download them all, but at the same time keep the directory structure of the website.

So for example i have these links:

http://www.mysite.com/zips/big/big1.zip
http://www.mysite.com/zips/big/big2.zip
http://www.mysite.com/zips/small/small1.zip
http://www.mysite.com/zips/small/small2.zip
http://www.mysite.com/rars/big/big1.rar
http://www.mysite.com/rars/big/big2.rar
http://www.mysite.com/rars/small/small1.rar
http://www.mysite.com/rars/small/small2.rar

I would like wget to store downloaded files on my disk in the following way:

Code:

start folder
|--zips
|  |--big
|  |  |--big1.zip
|  |  |--big2.zip
|  |--small
|  |  |--small1.zip
|  |  |--small2.zip
|--rars
|  |--big
|  |  |--big1.rar
|  |  |--big2.rar
|  |--small
|  |  |--small1.rar
|  |  |--small2.rar

Is this possible with wget?

Thanks!

colucix 05-14-2009 07:25 AM

Code:

wget -x -nH $link
should do the trick, where -x forces creation of directories and -nH don't create host directory, as www.mysite.com/.

Eddie1506 05-14-2009 08:17 AM

Quote:

Originally Posted by colucix (Post 3540438)
Code:

wget -x -nH $link
should do the trick, where -x forces creation of directories and -nH don't create host directory, as www.mysite.com/.

Thanks! It works flawlessly.

I saw those options btw, but somehow I presumed they were only meant to be used with recursive downloading and not with an url list.

colucix 05-14-2009 08:26 AM

Quote:

Originally Posted by Eddie1506 (Post 3540486)
I saw those options btw, but somehow I presumed they were only meant to be used with recursive downloading and not with an url list.

The -x option is not needed together with -r, since it is implicit in recursion, while the -nH option does its job even with recursion.


All times are GMT -5. The time now is 09:55 PM.