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?


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 May 23 '18 at 14:11
  • 6
    @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. – Iman Mohamadi May 29 '18 at 5:30

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

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 Nov 2 '16 at 20:36
  • Try it out and check which is best – Sairam62cse Nov 5 '16 at 2:47
  • Actually, he can check the man page and see what those options do. As I will – userDepth Jul 21 '17 at 12:31
  • 1
    c: force resume download -- i: ignore errors (like unavailable video) -- o: output location – damccull Jul 6 at 18:44

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...
  • 1
    better replace "2d" with "02d" to get e.g. "01 - title" instead of " 1 - title" names. – atmin Dec 10 '18 at 3:30
  • @atmin - 2d does that already. – Nabil Kadimi Dec 10 '18 at 13:26
  • it didn't for me, youtube-dl --version2018.12.09 – atmin Dec 11 '18 at 16:10
  • It didn't for me either. My youtube-dl version is 2019.06.27. Using "02d" worked. – John Pankowicz Jul 12 at 13:51

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

protected by Community Mar 15 '17 at 8:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.