Hitu Bansal
Hitu Bansal

Reputation: 3137

Wget how to save file in particular location

I am using this command

wget -r --accept "*.ext" --level 2 "example.com/index1/"

which is working fine. now i want to define path and file name where i want to save my file

Any suggestions

Thanks

Upvotes: 1

Views: 4030

Answers (2)

5gon12eder
5gon12eder

Reputation: 25449

You can use the -O option of wget. For example:

wget -O report.pdf http://www.example.com/files/awkward-name.pdf

Note however, that it is only really useful if you are downloading a single document.

From the manual page:

Use of -O is not intended to mean simply “use the name file instead of the one in the URL;” rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all downloaded content will be written there.

Since you appear to be using the -r option, you might be better off downloading all files into a temporary current working directory and only after that is done decide what to do with them.

mkdir /tmp/download/
cd /tmp/download/
wget http://www.example.com/files/awkward-name.pdf
cd -
cp /tmp/download/awkward-name.pdf report.pdf
rm -rf /tmp/download/

Upvotes: 1

SMA
SMA

Reputation: 37083

You could use -O option with wget like below:

wget google.com -O \usr\user\myfolder\foo.html

Upvotes: 1

Related Questions