Variables in moving / renaming files using CURL to download
curl -L http://URL/file[1-2].txt -o $(date +%m-%d-%y)\ newfilename{1,2}.txt
Basically, this command goes to URL, downloads file1.txt and file2.txt, however it saves BOTH files as newfilename1.txt I would like the script to name the second download (file2.txt) newfilename2.txt So, before you say to use the -O switch in Curl, please understand that I wish to rename the files so that they are not what they were on the server (names are too long). so file1.txt becomes newfilename1.txt, file2.txt becomes newfilename2.txt Is this possible? The command I listed works only until the newfilename{1,2}.txt, it always saves as newfilename1.txt |
Or, maybe another way would be to append a number at the end, like with the $(date) command?
Is there a command to add a number to the end of a file based on what files already exist? |
Try
Code:
curl -L http://URL/file[1-2].txt -o $(date +%m-%d-%y)\ newfilename#1.txt The variable #1 refers to the first [ ] or { } found in the URL. #2 refers to the second, and so on. Some examples are given in the -o section of the curl man page. |
Quote:
The first file (#1) is created with 355 bytes. The second file is created in the correct file size. :( |
All times are GMT -5. The time now is 02:59 PM. |