How to specify the location with wget?

Léo Léopold Hertz 준영 picture Léo Léopold Hertz 준영 · Jul 3, 2009 · Viewed 611.7k times · Source

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?

Answer

RichieHindle picture RichieHindle · Jul 3, 2009

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.