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?

5 Answers 5


The best solution I found is:

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" <playlist_link>
  • 1
    What is the difference between %(playlist_index)s and %(autonumber)s?
    – Flimm
    Commented May 23, 2018 at 14:11
  • 8
    @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. Commented May 29, 2018 at 5:30
  • 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.
    – user919062
    Commented Apr 28, 2020 at 13:21
  • 6
    I would even go as far as: %(playlist_index)02d for playlists 10-99 items long. Commented Sep 29, 2021 at 13:53
  • @TomaszGandor Exactly what I was looking for! Though it do add 0 if more then 9 items, I want to have 0N for conformity :) Commented Dec 21, 2021 at 20:51

I think using

youtube-dl --auto-number url

will do it.

  • 2
    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. Commented Nov 7, 2015 at 10:14
  • @ImanMohamadi Could you please post what you did to fix the issue you mentioned? Commented Oct 31, 2016 at 11:25
  • 1
    @IgorStoppa I've already added it as an answer my self and choose it a the best solution. see above. Commented Nov 2, 2016 at 5:05
  • 6
    "WARNING: --auto-number is deprecated. Use -o "%(autonumber)s-%(title)s.%(ext)s" instead." Commented Jan 18, 2019 at 7:22

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

youtube-dl -o "%(playlist_index)02d - %(title)s.%(ext)s" PLaPV8TkYEUV05rhlfVKXKqxvTkQ_3Tqek
#                               .
#                              /|\
#                               |
  • 11
    better replace "2d" with "02d" to get e.g. "01 - title" instead of " 1 - title" names.
    – atmin
    Commented Dec 10, 2018 at 3:30
  • 2
    @atmin - 2d does that already. Commented Dec 10, 2018 at 13:26
  • 3
    it didn't for me, youtube-dl --version2018.12.09
    – atmin
    Commented Dec 11, 2018 at 16:10
  • 5
    It didn't for me either. My youtube-dl version is 2019.06.27. Using "02d" worked. Commented Jul 12, 2019 at 13:51
  • 1
    @SergioAraujo, that file is not available right now.
    – nyxee
    Commented Jun 11, 2022 at 1:55

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'
  • 2
    How is this answer any better then the accepted answer?
    – Fabby
    Commented Nov 2, 2016 at 20:36
  • Try it out and check which is best Commented Nov 5, 2016 at 2:47
  • Actually, he can check the man page and see what those options do. As I will
    – userDepth
    Commented Jul 21, 2017 at 12:31
  • 2
    c: force resume download -- i: ignore errors (like unavailable video) -- o: output location
    – damccull
    Commented Jul 6, 2019 at 18:44

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

rename 's/000//g' *

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' *

You must log in to answer this question.

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