8

I am using Ubuntu 14.04 and youtube-dl to download videos. How can I download videos in respective directory?

e.g. Playlist name is: MyPlaylist, that contains several videos

how can I download videos in directory like: MyPlaylist/index_title.ext

3
  • have you really not considered specifying an mv command after, to move the file where you want it to be
    – barlop
    Commented Oct 30, 2015 at 16:05
  • @barlop I wanted to do it on-the-go, with some inbuilt option in youtube-dl. Look at the accepted answer, that perfectly resolves my query. Commented Oct 31, 2015 at 4:26
  • Sure but you could have put in your question that you wanted to do it without mv, and using functionality of youtube-dl
    – barlop
    Commented Oct 31, 2015 at 11:58

3 Answers 3

13

Have you checked the documentation? Specifically the -o, --output option. Using that, you should be able to do:

youtube-dl -o '/home/me/%(playlist_title)s/%(playlist_index)s_%(title)s.%(ext)s'

That said, please be sure to respect the owner's rights with any videos you use this program for.

2
  • Thanks, That saved me a lot of work. And I'll keep the disclaimer in mind. Commented Oct 31, 2015 at 4:20
  • @nerdwaller Can you update your answer to add a missing single quote at the end of the code snippet?
    – Nate
    Commented Jul 4, 2020 at 3:32
1

See Output template examples. https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template-examples

# Download YouTube playlist videos in separate directory indexed by video order in a playlist
$ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re

# Download all playlists of YouTube channel/user keeping each playlist in separate directory:
$ youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists

My example.

youtube-dl -ci -o "~/dl.folder/%(playlist_title)s/%(title)s-%(id)s.%(ext)s" --write-sub --convert-subs srt -k --download-archive archive.txt --proxy socks5://127.0.0.1:1080/ https://www.youtube.com/channel/UCzBGtBze1AIcDmRwD2ZjiAA

-o, --output TEMPLATE Output filename template, see the "OUTPUT TEMPLATE" for all the info

~

-c, --continue Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.

~

-i, --ignore-errors Continue on download errors, for example to skip unavailable videos in a playlist

~

--download-archive FILE Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.

~

--proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper scheme. For example socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") for direct connection

~

--write-sub Write subtitle file

~

-k, --keep-video Keep the video file on disk after the post-processing; the video is erased by default

~

--convert-subs FORMAT Convert the subtitles to other format (currently supported: srt|ass|vtt|lrc)

ref:

https://ytdl-org.github.io/youtube-dl/index.html

https://github.com/ytdl-org/youtube-dl/blob/master/README.md

https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template

youtube-dl --help (youtube-dl --version 2019.08.13)

0

I want to update the answer by adding the playlist links in a file. Then download each playlist in its respective folder .

youtube-dl -f best -o '%(playlist_title)s/%(playlist_index)s_%(title)s.%(ext)s' -a list_of_playlist_links.txt

This will create a folder for each playlist and download the playlist. The playlists will be saved in the same directory of the file list_of_playlist_links.txt

You must log in to answer this question.

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