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?
Asked
Active
Viewed 9.2k times
5 Answers
154
The best solution I found is:
youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" <playlist_link>

Iman Mohamadi
- 2,795
20
I think using
youtube-dl --auto-number url
will do it.

SarpSTA
- 1,011
-
2This 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 07 '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 02 '16 at 05:05
-
6"WARNING: --auto-number is deprecated. Use -o "%(autonumber)s-%(title)s.%(ext)s" instead." – Boris Pavlović Jan 18 '19 at 07:22
17
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
# .
# /|\
# |

Nabil Kadimi
- 2,212
-
11better replace "2d" with "02d" to get e.g. "01 - title" instead of " 1 - title" names. – atmin Dec 10 '18 at 03:30
-
2
-
3
-
5It didn't for me either. My youtube-dl version is 2019.06.27. Using "02d" worked. – John Pankowicz Jul 12 '19 at 13:51
-
I am sharing an youtube-dl config file with interesting options including this one – SergioAraujo Nov 14 '20 at 14:46
-
1
10
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'

Fabby
- 34,259

Sairam62cse
- 101
-
2
-
-
Actually, he can check the man page and see what those options do. As I will – userDepth Jul 21 '17 at 12:31
-
2c: force resume download -- i: ignore errors (like unavailable video) -- o: output location – damccull Jul 06 '19 at 18:44
3
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' *

shantiq
- 567
%(playlist_index)s
and%(autonumber)s
? – Flimm May 23 '18 at 14:11%(playlist_index)02d
for playlists 10-99 items long. – Tomasz Gandor Sep 29 '21 at 13:530
if more then 9 items, I want to have0N
for conformity :) – user3342816 Dec 21 '21 at 20:51