How to download a youtube playlist with numbered prefix via youtube-dl?

74,600

Solution 1

The best solution I found is:

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" <playlist_link>

Solution 2

I think using

youtube-dl --auto-number url

will do it.

Solution 3

Use the -o option with playlist_index and the format <n>d like this:

youtube-dl -o "%(playlist_index)2d - %(title)s.%(ext)s"
#                               .
#                              /|\
#                               |

or 3d or 4d and so on, as in C's printf:

  • Using 2d, you get numbers starting from 01
  • Using 3d, you get numbers starting from 001
  • And so on...

Solution 4

Please use the below link to download playlist in numbers in increment at first followed by title of the content

youtube-dl -cio '%(autonumber)s-%(title)s.%(ext)s' 'Paste your playlist link'

Solution 5

excellent! but it leaves you with a file called 00001nameoffile
so run:

rename 's/000//g' *

afterwards
to get 01,02,03 etc
For this line below

youtube-dl -cio '%(autonumber)s-%(title)s.%(ext)s' 'Paste your playlist link'

or as one line:

youtube-dl -cio '%(autonumber)s-%(title)s.%(ext)s' url ; rename 's/000//g' *

Share:
74,600

Related videos on Youtube

Iman  Mohamadi
Author by

Iman Mohamadi

Updated on September 18, 2022

Comments

  • Iman  Mohamadi
    Iman Mohamadi almost 2 years

    I have a Youtube playlist, I want to download it but I want youtube-dl to name the files like 1-{name}, 2-{name}, ... n-{name} in order to be able to watch them in the same sequence as original Youtube playlist. In other words I need my downloaded videos to be prefixed with numbers. How can I do that?

  • Iman  Mohamadi
    Iman Mohamadi over 8 years
    This is grate, Only one single issue and that's it messes with the names and replace a part of their names with a number. I fixed my issue myself by getting the main idea from your answer.
  • Igor Stoppa
    Igor Stoppa over 7 years
    @ImanMohamadi Could you please post what you did to fix the issue you mentioned?
  • Iman  Mohamadi
    Iman Mohamadi over 7 years
    @IgorStoppa I've already added it as an answer my self and choose it a the best solution. see above.
  • Fabby
    Fabby over 7 years
    How is this answer any better then the accepted answer?
  • Sairam62cse
    Sairam62cse over 7 years
    Try it out and check which is best
  • userDepth
    userDepth almost 7 years
    Actually, he can check the man page and see what those options do. As I will
  • Flimm
    Flimm about 6 years
    What is the difference between %(playlist_index)s and %(autonumber)s?
  • Iman  Mohamadi
    Iman Mohamadi about 6 years
    @Flimm autonumber uses the number in your download queue, if you restart the download it will be reset. playlist_index uses index of video in playlist and is a better option if you want to stop and resume your download later.
  • atmin
    atmin over 5 years
    better replace "2d" with "02d" to get e.g. "01 - title" instead of " 1 - title" names.
  • Nabil Kadimi
    Nabil Kadimi over 5 years
    @atmin - 2d does that already.
  • atmin
    atmin over 5 years
    it didn't for me, youtube-dl --version2018.12.09
  • fran tardencilla
    fran tardencilla over 5 years
    "WARNING: --auto-number is deprecated. Use -o "%(autonumber)s-%(title)s.%(ext)s" instead."
  • damccull
    damccull almost 5 years
    c: force resume download -- i: ignore errors (like unavailable video) -- o: output location
  • John Pankowicz
    John Pankowicz almost 5 years
    It didn't for me either. My youtube-dl version is 2019.06.27. Using "02d" worked.
  • Admin
    Admin about 4 years
    Any idea on resolving when playlist index has been changed overtime? I already have alot of downloaded videos but their index is messed up. I don't wish to rename each one of them individually.
  • SergioAraujo
    SergioAraujo over 3 years
    I am sharing an youtube-dl config file with interesting options including this one
  • Tomasz Gandor
    Tomasz Gandor over 2 years
    I would even go as far as: %(playlist_index)02d for playlists 10-99 items long.
  • user3342816
    user3342816 over 2 years
    @TomaszGandor Exactly what I was looking for! Though it do add 0 if more then 9 items, I want to have 0N for conformity :)