11

I've been downloading videos with youtube-dl using upload_date in the name of the file. This puts the date in YYYYMMDD format in the name file, but I will find more convenient if I could store them in something like:

  • YYYY-MM-DD
  • DD-MM-YYYY

I know youtube-dl does not provide that option, but is there any other way of doing this (either on Linux or Windows)? The only I can think of is mass renaming with mmv after downloading every file.

Right now I use the output template:

"%(upload_date)s-%(title)s.%(ext)s"
40detectives
  • 287
  • 1
  • 2
  • 9

2 Answers2

6

There is no way to change it in youtube-dl, but you can use its more advanced fork yt-dlp and use the following output format:

%(upload_date>%Y-%m-%d)s

Working example:

yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 --output "%(uploader)s - %(upload_date>%Y-%m-%d)s - %(title)s [%(id)s].%(ext)s" <URL>

Source: official documentation.

1

With the perl-flavoured rename command, you could write:

rename 's/^(\d{4})(\d{2})(\d{2})/$1-$2-$3/' [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-*

I recommend you use the ISO standard YYYY-MM-DD date format: it is unambiguous and it sorts the same lexically and chronologically.

glenn jackman
  • 27,524