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"
1
  • 2
    Thanks for the tip how to add date at the beginning of the filename!
    – pbies
    Dec 28, 2020 at 0:58

2 Answers 2

4

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.

3
  • Huge thanks for this, that's the perfect solution for the upload dates! But beware, don't use the bestvideo[ext=mp4] stuff. The yt-dlp developers have warned that this leads to lower quality downloads and lower resolution files, because YouTube prioritizes webm/VP9 for the best qualities. As an extra tip: I wanted the videos to be sorted by playlists, so this is the output format I ended up with: -o '%(playlist)s/[%(upload_date>%Y-%m-%d)s] %(title)s [%(id)s].%(ext)s' May 25, 2023 at 2:24
  • @MitchMcMabers thank you for this suggestion. What would be a better way to get the best video and audio quality? May 26, 2023 at 16:15
  • 1
    Accepted this because yt-dlp is kinda the way to go these days (youtube-dl is kinda outdated). Btw, you'd probably want to change the working example to use yt-dlp instead of youtube-dl. In reference to what @MitchMcMabers said, I usually try first a "-F" on the URL and pick my preferred quality and format from there. Oct 7, 2023 at 10:44
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .