Batch download videos with yt-dl and bash.

Do you need to download multiple or large amounts of video? Manually copying and pasting URLs to yt-dlp can be tedious and time-consuming. In this blog post, I will guide you through the simple bash script I created to automate downloading videos from a text files.

Part_1: Creating the script..

  1. Open a text editor and create a new file named batchdown (you can name the file whatever you like).

  2. Paste the code below into the newly created file..

#!/bin/env bash

while IFS= read -r line; do
  yt-dlp "$line"
done < "$1"

echo "DOWNLOAD FINISHED !!."

The script is a basic bash loop that iterates through each line in the text file and uses yt-dlp to download from the listed URLs. Finally, it displays a finished message when all downloads have finished.

  1. Save the script to your .local/bin directory. 3.1. You’ll need to manually create this directory if it does not already exist.

    mkdir -p ~/.local/bin
    

    3.2. You’ll also need to add the directory to your path. This can be done by adding the following line to your .bashrc file. export PATH="/home/yourusernamegoeshere/.local/bin:$PATH"

  2. Make the script executable.

    chmod +x batchdown
    

Part_2: Using the Script..

  1. Open a new terminal window and navigate to the directory containing your text file.
  2. Run the script with your text file as an argument:
    batchdown downloads.txt
    
  3. The script will automatically download each video listed in your text file.

Please take into consideration that downloading copyrighted content without permission is illegal. Please use this script responsibly.

Related posts