0

I have a .txt file with a list of .m3u8 links. I want to batch download all these links (videos) without having to manually enter them one by one.

The problem I'm having is this: youtube-dl is giving the output files the SAME NAME, and this is stopping me from batch downloading files, because after the first file is downloaded, I get the error message (for the following files) that this file already exists.

So because the same name is being applied to any download, I'm not able to download more than one file at a time.

Can someone please help with a solution?

0

Use -o option:

youtube-dl -a batch_file \
 -o "%(title)s by %(uploader)s on %(upload_date)s in %(playlist)s.%(ext)s" 

-o, --output TEMPLATE

Output filename template, see the "Output Template" for all the info

There are a lot of patterns you can use differentiate files from each other.

id (string): Video identifier
display_id (string): An alternative identifier for the video
timestamp (numeric): UNIX timestamp of the moment the video became available
duration (numeric): Length of the video in seconds
view_count (numeric): How many users have watched the video on the platform
like_count (numeric): Number of positive ratings of the video
...

https://www.mankier.com/1/youtube-dl#Output_Template

2
  • Thank you so much for your answer @Ravexina! I'm really grateful. Sorry for responding late - I was testing out different possibilities you suggested, but still having trouble, because when I run the following command, then the files don't render correctly: youtube-dl -a batch-file.txt -o "%(title)s by %(url)s" I've also tried other possibilities, but the file doesn't download completely & VLC player shows me errors when playing it (even though youtube-dl tells me that files were 100% downloaded successfully - though the file sizes are much smaller than they're supposed to be). – Shay Singh May 18 '20 at 4:01
  • %(url)s could be a troubling variable to use within a filename, try something more simple like %(id)s to see if that does the trick. – ShaneB Jan 5 at 0:28
0

If the filename is not a major concern, especially while testing, I would recommend using the autonumber variable and a simple id:

youtube-dl --batch-file batch_file.txt -o "File %(autonumber)s (%(id)s).%(ext)s"

As mentioned in the comment above, using a url variable in a filename could be troublesome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.