Reputation: 4502
I want to use wget so that my file takes on the name I want. For example, if I do wget -r http://www.x.com/y/z
, the main file will be named z
, even though it's actually index.html
.
I checked the -O
option of wget, but according to the manual:
‘-O file’
‘--output-document=file’
The documents will not be written to the appropriate files, but all will be concatenated together and written to file. ...
It seems like all the files will be concatenated and written to the file of the desired name. I would like only the main file (and not any file resulting from recursion) to be concatenated. How can I do that?
Upvotes: 20
Views: 16976
Reputation: 5182
From what I understand you want to concatenate the file that the server points to and download all the files into one place recursively on the site.
concatenate:
wget -qO- http://www.google.com
recursive download to one place:
wget --mirror -p --convert-links -P ./LOCAL-DIR http://www.google.com
Where LOCAL-DIR is the one directory all the directories will be downloaded to. From this site:
http://www.thegeekstuff.com/2009/09/the-ultimate-wget-download-guide-with-15-awesome-examples/
Upvotes: 0
Reputation: 25557
Leave out the -r
if you only want the main file:
wget -O customFileName http://www.x.com/y/z
wget
does not support renaming just one file of a recursive download. Remember that filenames correspond to parts of the URL and renaming the file would break links between files. You can always either break it in two:
wget -O customFileName http://www.x.com/y/z
wget -r http://www.x.com/y/z
or just rename the file yourself:
wget -r http://www.x.com/y/z
mv z customFileName
Upvotes: 37
Reputation: 1711
Try appending a /
to the end of the URL:
$ wget -r http://www.x.com/y/z/
This results in an index.html
file being saved instead of a z
file
Upvotes: 3