I have a long list of files to download with the following syntax:


Of course YYYY is the year, MM the month, DD the day.

Is there a way to download the files on this list and assign each of them a name in the form YYYY-MM-DD.pdf? Or to keep the directories and have each file.pdf in its proper directory?

  • Where are you getting this list from? Is it in a file? have you tried anything? – j-money Mar 12 '19 at 15:50
  • The list was in a file – Federico D'Ambrosio Mar 13 '19 at 13:06

You essentially have two options here, and depending on how and where you're getting the list of files from, one may be better than the other:

  1. You have a list of all URLs: In this case, your only choice is to write a script that reads each line, parses the URL and invokes Wget with the right output filename. This is extremely easy to do (~5 lines of bash)

  2. The website has a listing / index.html page that links to all the files you want. This allows you to call wget recursively with the -r option. In this case, the entire file hierarchy will be preserved.


You cannot rename the files while downloading them. wget will preserve the directory structure, and you may rename the files to your desired naming convention later. Read man wget (or https://manpages.ubuntu.com/manpages/bionic/en/man1/wget.1.html )

  • What about ` -O file` / ` --output-document=file` ? Like wget -O YYYY-MM-DD.pdf https://url.url/YYYY/MM/DD/file.pdf – Soren A Mar 12 '19 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.