With youtube-dl I can do

# 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

the above script downloads the playlist by creating a folder with the name of the playlist and then downloads the individual videos into that folder.

I also can do

$ youtube-dl -citw --batch-file=downloads.txt

this script downloads all the video urls list in the batch file, the file can contain playlists as well as individual url's and youtube-dl downloads all videos in the current directory.

I now somehow want to marry both of these. If i have a text file containing playlist links. I want to download all those playlist in to its own folder like I do with the 1st command.

Can I do that with youtube-dl ?

3 Answers 3


If downloads.txt contains one url per line try:

cat downloads.txt | xargs -n1 youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'
  • yes I have one url per line ... and I should have mentiond it earlier but i'm doing this on a windows system.. Mar 29, 2017 at 15:58
  • 1
    Either install cygwin and use that line above, or install microsoft powershell and ask a new question how to translate that line to powershell.
    – Michael D.
    Mar 29, 2017 at 16:06
  • In powershell you can do $downloadLinks = Get-Content download.txt and then loop thru each of those lines using foreach($downloadLink in $downloadLinks) and then do whatever processing you want in the foreach loop Mar 30, 2017 at 4:31
  • this works so well.
    – Denis
    Nov 21, 2020 at 13:37

In case people from the future stumbled upon this post, I've found a solution working on Windows. Don't know about other OS though.

In your x:\Users\USERNAME\ , create or edit a file named youtube-dl.conf and paste the commands below. This would always run in youtube-dl so you don't have to type it in the terminal. For more info about the config file.

-o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'

After that, create a text file containing the playlist links separated by a line and run this.

youtube-dl --batch-file=downloads.txt

After downloading, you're free to delete the commands in youtube-dl.confif you don't need it.

  • The config file is not a necessary part of this - you can simply include the -o switch when running the command on the command line. The config file is for command-line switches you use often enough to avoid typing them on the command line. I would also recommend anyone using YouTube-DL in 2021 to migrate to the yt-dlp fork, which is actively developed, more reliable, and much more fully featured. The sole developer of YouTube-DL went on a very long hiatus leaving the project essentially buried compared to the work other forks have done on top of it. Nov 16, 2021 at 11:56

A solution for Windows and Linux:

yt-dlp -o "%(playlist_title)s/%(title)s.%(ext)s" --batch-file=downloads.txt

This will create subfolders per playlist with the playlist name as the folder name. Non-playlist videos will get downloaded to a folder named "NA".

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

You must log in to answer this question.

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