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..
Open a text editor and create a new file named
batchdown
(you can name the file whatever you like).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.
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"
Make the script executable.
chmod +x batchdown
Part_2: Using the Script..
- Open a new terminal window and navigate to the directory containing your text file.
- Run the script with your text file as an argument:
batchdown downloads.txt
- The script will automatically download each video listed in your text file.