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?
By default, downloaded file will be saved with the last name mentioned in the URL. To save file with a different name option O can be used. Syntax: wget -O <fileName><URL>
Use wget --content-disposition <url> Explanation: The Content-Disposition header can be used by a server to suggest a filename for a downloaded file. By default, wget uses the last part of the URL as the filename, but you can override this with --content-disposition , which uses the server's suggested name.
The main difference between them is that curl will show the output in the console. On the other hand, wget will download it into a file.
With wget , you can download multiple files, resume partial downloads, mirror websites, and combine the Wget options according to your needs.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With