Skip to content

Instantly share code, notes, and snippets.

@vincent-zurczak
Last active November 27, 2017 21:45
Show Gist options
  • Save vincent-zurczak/19f140991e436a035837dbb10389023d to your computer and use it in GitHub Desktop.
Save vincent-zurczak/19f140991e436a035837dbb10389023d to your computer and use it in GitHub Desktop.
Batch script to download Youtube videos from a listing file (one video per line)
#!/bin/bash
# Configuration
DL_DIR="/wherever/you/want"
INPUT="/wherever/is/your/file"
# We need "youtube-dl" (https://github.com/rg3/youtube-dl).
# We here download the best video quality.
# One Youtube address per line. Empty lines are ignored.
mkdir -p $DL_DIR && cd $DL_DIR
while IFS='' read -r line || [[ -n "$line" ]]; do
if [ -n "$line" ]; then
youtube-dl -f 'bestvideo[ext=mp4]/bestvideo/best' $line
fi
done < $INPUT
rem On Windows, the ffmpeg executable should be referenced in the system path.
rem Or it should be located in the same directory than youtube-dl.exe.
rem -w: no overwrite
rem
for /F "tokens=*" %%A in (I:\path\to\my\list.txt) do I:\executables\youtube-dl.exe -w -f "bestvideo[ext=mp4]+bestaudio" %%A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment