How to download a youtube playlist with numbered prefix via youtube-dl?
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' *
Related videos on Youtube
![Iman Mohamadi](https://i.stack.imgur.com/epJjF.jpg?s=256&g=1)
Iman Mohamadi
Updated on September 18, 2022Comments
-
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 over 8 yearsThis 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 over 7 years@ImanMohamadi Could you please post what you did to fix the issue you mentioned?
-
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 over 7 yearsHow is this answer any better then the accepted answer?
-
Sairam62cse over 7 yearsTry it out and check which is best
-
userDepth almost 7 yearsActually, he can check the man page and see what those options do. As I will
-
Flimm about 6 yearsWhat is the difference between
%(playlist_index)s
and%(autonumber)s
? -
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 over 5 yearsbetter replace "2d" with "02d" to get e.g. "01 - title" instead of " 1 - title" names.
-
Nabil Kadimi over 5 years@atmin -
2d
does that already. -
atmin over 5 yearsit didn't for me,
youtube-dl --version
→2018.12.09
-
fran tardencilla over 5 years"WARNING: --auto-number is deprecated. Use -o "%(autonumber)s-%(title)s.%(ext)s" instead."
-
damccull almost 5 yearsc: force resume download -- i: ignore errors (like unavailable video) -- o: output location
-
John Pankowicz almost 5 yearsIt didn't for me either. My youtube-dl version is 2019.06.27. Using "02d" worked.
-
Admin about 4 yearsAny 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 over 3 yearsI am sharing an youtube-dl config file with interesting options including this one
-
Tomasz Gandor over 2 yearsI would even go as far as:
%(playlist_index)02d
for playlists 10-99 items long. -
user3342816 over 2 years@TomaszGandor Exactly what I was looking for! Though it do add
0
if more then 9 items, I want to have0N
for conformity :)