How do I preserve the remote filename when Downloading a file using curl [duplicate]
Possible Duplicate:
How do I save a file using the response header filename with cURL
I need to download many thousands of images in the format
http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=0
If you paste that link in a browser, it tries to download a file named 1.jp2
I want to use curl to do the same. However, when I run
curl -I 'http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=0'
开发者_运维技巧the filename is reported as 404.txt which you can download and see that it is actually the file I want. I can't use the -O option because the name assigned to the file is no good, and I have technical reasons for needing the actual name used on the system.
How do I get curl to download the same file I have no trouble retrieving in my browser? Thanks.
The solution is to use -O -J
-O, --remote-name Write output to a file named as the remote file -J, --remote-header-name Use the header-provided filename
So...
curl -O -J 'http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=0'
I had to upgrade my CURL. I had v 7.19 which doesn't support -J but 7.22 (which is the latest) does.
You can use the -o option can you? eg
curl 'http://oregondigital.org/cgi-bin/showfile.exe?CISOROOT=/baseball&CISOPTR=[0-9]' -o "#1.jpg"
精彩评论