I'm downloading files from a POST endpoint using a command on the form
while true; do curl -O -J http://domain/endpoint; done
This endpoint "returns" a new file on each POST call. Curl gives each file the filename given by the Content-Disposition header.
The problem is that the server gives the same filename for several of the files. Are there any easy ways to append a postfix to the filename, e.g. use "filename_1.pdf" instead of "filename.pdf" if a file named "filename.pdf" already exists in the folder?