0

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?

Termininja
  • 6,620
  • 12
  • 48
  • 49

2 Answers2

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]}" curl -s -o "${filenames[i]}" curl -s -o "${filenames[i]}" ` – Esai Giovanni Jun 05 '16 at 18:15