Is there's a command to download files with curl from the same page and rename it with numbers or timestamps instead or rewritten the file with the .php
file? I mean the url is downloadfile.php?id=1500
so when I set the option -O
I get a file called downloadfile.php
and if I download the id=1501
the downloadfile.php
is rewritten it is possible to set curl to rename every curl request to number or timestamp like downloadfile00001.php
?
Asked
Active
Viewed 1,172 times
0

Termininja
- 6,620
- 12
- 48
- 49

Esai Giovanni
- 11
- 1
-
[This might be a duplicate](http://stackoverflow.com/questions/9744973/is-there-a-way-to-give-a-specific-file-name-when-saving-a-file-via-curl-in-mac-o) – theatlasroom Jun 05 '16 at 05:12
-
curl -o
2 Answers
0
If you're using flags it sounds like you are working on the commandline. -O uses the same name as the remote file. -o means write to file with whatever name you want. So in your script be it bash or what have you, you would use a variable you increment with the version you want.
example: curl website.com -o websitenamefileiwant.html

alanmbarr
- 142
- 2
- 7
0
in bash scripting you'd do this
filenames=( filename1.html filename2.html filename3.html )
curl -s -o "${filenames[i]}" <url>
or you can do this on the command line
sudo curl http://path-to-url/downloadfile.php?id=1500 -o downloadfile00001.php

unixmiah
- 3,081
- 1
- 12
- 26
-
Thanks I tried the bash script but when I run I get filename1.html and that is rewritten again. `filenames=( filename1.html filename2.html filename3.html ) curl -s -o "${filenames[i]}"
curl -s -o "${filenames[i]}" – Esai Giovanni Jun 05 '16 at 18:15curl -s -o "${filenames[i]}" curl -s -o "${filenames[i]}" `