I am using download.file to get mp3 files from a website which already allows you to download them (no funny business going on here!) but I want to create a function that scales up to get all the bird songs and very importantly give the right names to the files.
In the example script below you can see how to get one mp3 quite easily but note that the mp3 file is just named "3900" this page is found by going to the bird of choice's site such as the bearded reedling then right clicking on the play button for the song and opening it in a new tab which gives a nonsensical url "https://www.vogelwarte.ch/assets/media/voices/3900.mp3" in relation to the bird name
download.file(url = "https://www.vogelwarte.ch/assets/media/voices/3900.mp3"
, destfile="~/Desktop/Birdsongs/bearded-reedling.mp3"
, method="auto"
, quiet = FALSE
, cacheOK = TRUE
, mode="wb"
, extra = getOption("download.file.extra")
, headers = NULL)
So my question is how can I keep some kind of consistent file naming while looping through all the bird names on the site so that I know which file belongs to which bird?