Glam Prestige Journal

Bright entertainment trends with youth appeal.

So after some time of searching on Google and Super User (and scanning man pages) I was unable to find an answer to something that (I think) should be simple:

If you go here:

And try to download the theme:

Like so:

wget 

You’ll probably end up with a file called download_script.php?src_id=9750.

But I want it to be called molokai.vim, which is what would happen if I used a browser to download this file.

What options do I need to specify for wget for the desired effect?

I'd also be ok with a Curl equivalent command.

4 Answers

-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. If - is used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally named -.)

So,

wget -O somefile.extension '

Or, you may be able to get wget to automatically use the filename proposed by the server using the --content-disposition option if supported by your version.

wget --content-disposition '

Caveats as per the man page,

--content-disposition

If this is set to on, experimental (not fully-functional) support for "Content-Disposition" headers is enabled. This can currently result in extra round-trips to the server for a "HEAD" request, and is known to suffer from a few bugs, which is why it is not currently enabled by default.

This option is useful for some file-downloading CGI programs that use "Content-Disposition" headers to describe what the name of a downloaded file should be.

You can achieve the same automated behavior with curl, using,

curl -JLO '

-O uses the remote name, and -J forces the -O to get that name from the content-disposition header rather than the URL, and -L follows redirects if needed.

11

With wget you can do this:

wget --trust-server-names <url> 

to save the file using the last file name the server gives you.

6

You could also use aria2c - it seems to work nicely with the Content-Disposition headers.

Worked by following:

curl -o molokai.vim

wget -O somefile.extension

(changed case to smaller i.e. (the wget -O) to (wget -o)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy