Last active
November 18, 2025 06:18
-
-
Save infojunkie/321531f3954cea9fc7925fb3312e27ac to your computer and use it in GitHub Desktop.
Rip a folder with HandBrakeCLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # Given a parent folder, find all DVD images (*.iso files and VIDEO_TS folders) | |
| # Convert all titles within each DVD image to mkv using HendBrakeCLI with a hard-coded preset | |
| # | |
| # Prerequisites: xmllint, lsdvd, HandBrakeCLI | |
| # | |
| #!/usr/bin/env bash | |
| OLDIFS=$IFS | |
| IFS=$'\n' | |
| for f in $(find "$1" -name '*.iso' -or -name 'VIDEO_TS'); do | |
| tracks=$(lsdvd -Ox "$f" | sed 's/&/\&/g' | xmllint --xpath "count(//track)" -) | |
| dirname=$(dirname "${f/"$1"/}") | |
| dirname=${dirname/\/$/} | |
| mkdir -p "$dirname" | |
| for ((i = 1; i <= ${tracks:-1}; i += 1)); do | |
| filename="$(basename "${f/.iso//}") - track $i.mkv" | |
| if [[ -f "$dirname"/"$filename" ]]; then | |
| echo Skipping "$dirname"/"$filename" | |
| else | |
| echo "$dirname"/"$filename" | |
| HandBrakeCLI -t $i --preset "H.265 MKV 1080p30" --input "$f" --output "$dirname"/"$filename" 2>/dev/null | |
| fi | |
| done | |
| done | |
| IFS=$OLDIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment