Changing name of the video while downloading via youtube-dl

46,495

Solution 1

Sometimes I had headache to rename and sort the files based on the order.

So to add auto-numbering, use -A like,

youtube-dl https://www.youtube.com/playlist?list=PLOU2XLYxmsILe6_eGvDN3GyiodoV3qNSC -A

Or to keep playlist index,

youtube-dl -o '%(playlist_index)s. %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLOU2XLYxmsILe6_eGvDN3GyiodoV3qNSC

This will add nice numbering to the downloaded files.

And if you are downloading files which is not in playlist, you can add numbers manually to the file,

youtube-dl -o "1-%(uploader)s%(title)s.%(ext)s" https://youtu.be/862r3XS2YB0

Here I have manually added 1- to the filename while downloading.

Solution 2

Use youtube-dl -o '%(playlist_index)s. %(title)s.%(ext)s' https://www.youtube.com/playlist?list=....

Solution 3

The best solution I found is:

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

For example:

youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" https://www.youtube.com/playlist?list=PLf8i4fc0zJBzLhOe6FwHpGhBDgqwInJWZ

Solution 4

'outtmpl': 'temp/' + str(i) +'.%(ext)s' 
Share:
46,495
Desmnd
Author by

Desmnd

Updated on July 05, 2022

Comments

  • Desmnd
    Desmnd about 2 years

    I am trying to download a complete playlist in youtube, while downloading i want to enter serial number while downloading in front of the title of the video,

    For example if a playlist has a videos:

    A.mp4
    E.mp4
    K.mp4
    C.mp4
    B.mp4
    

    I want it to be

    1. A.mp4
    2. E.mp4
    3. K.mp4
    4. C.mp4
    5. B.mp4.
    

    I tried commands like:

    i=0;youtube-dl -cti https://www.youtube.com/playlist?list={(Any Playlist)} -o "{{$i++}%(title)s.%(ext)s}"
    

    but its giving me this error:

    youtube-dl: error: using output template conflicts with using title, video ID or auto number

    Also, Downloading the whole playlist and then renaming one by one is also not i am searching.

    Is there any command which downloads the playlist and renames each video side by side according to my wish?

  • Desmnd
    Desmnd almost 9 years
    Sir, thank you it worked but you added playlist index, what if I have to add my own number in front instead the playlist index, what shall I do?
  • Eray Erdin
    Eray Erdin almost 7 years
    Just saying, -A option is deprecated, now it is recommended to use -o.
  • Andrew Savinykh
    Andrew Savinykh over 5 years
    What if you already downloaded a terabyte long playlist and now what to rename the file accordingly? ;) youtube-dl can download playlist metadata, but how to get this metadata in a form that can be used from a script to match already downloaded files and rename them?
  • codeitram
    codeitram about 3 years
    What to do if I already have downloaded the video and would like to rename it ?