Youtube-dl changing the format output of %(upload_date)s

bashbatchyoutube-dl

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"

Best Answer

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.

Related Question