Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the download location with wget?

Tags:

wget

I need files to be downloaded to /tmp/cron_test/. My wget code is

wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/ 

So is there some parameter to specify the directory?

like image 792
Léo Léopold Hertz 준영 Avatar asked Jul 03 '09 09:07

Léo Léopold Hertz 준영


2 Answers

From the manual page:

-P prefix --directory-prefix=prefix            Set directory prefix to prefix.  The directory prefix is the            directory where all other files and sub-directories will be            saved to, i.e. the top of the retrieval tree.  The default            is . (the current directory). 

So you need to add -P /tmp/cron_test/ (short form) or --directory-prefix=/tmp/cron_test/ (long form) to your command. Also note that if the directory does not exist it will get created.

like image 176
RichieHindle Avatar answered Oct 02 '22 18:10

RichieHindle


-O is the option to specify the path of the file you want to download to:

wget <uri> -O /path/to/file.ext 

-P is prefix where it will download the file in the directory:

wget <uri> -P /path/to/folder 
like image 24
RPradeep Avatar answered Oct 02 '22 18:10

RPradeep