Curl download file different name
I can use 1, but I need to have files named with different names I have stored those names in array. How can change output names for multiple files? You can iterate over two arrays, one with your URLs to download and another with your desired filenames, launching subprocesses that will run in parallel to download the files. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Learn more. Asked 7 years, 4 months ago. Active 7 years, 4 months ago. Viewed 3k times. Improve this question. Peter Peter 21 1 1 silver badge 4 4 bronze badges. So what if we want to use cURL to save a file to our server? For that, we must use the -O option:.
You'll notice that cURL will display a download progress table rather than the file contents this time:. If you'd like the file to have a different file name perhaps readme is too bossy for you , specify it after -O :. That's all well and good, but downloading lots of files in this way would quickly become a hassle.
You can download more than one file in a single command by using the following syntax:. If you have a long list of different files you want to download, you can place them in a text file and run cURL with xargs:. As it's common for site admins to move the location of a file, then redirect to the new one, it can be good practice to include the -L option in your cURL command. You can use the -o or --output option followed by a file name you want to save the output. If you want to download multiple files, you can add more -o or -O options:.
If the target server responded with the HTTP redirection code 3xx for the requested file, the local file you downloaded would be empty. In this case, you have to add the -L or --location option to tell cURL to follow the redirects.
The number of bytes can be abbreviated by appending a suffix: kilobytes k or K , megabytes m or M , and gigabytes g or G.
0コメント