Skip to content

Instantly share code, notes, and snippets.

@marcboivin
Created November 19, 2012 23:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marcboivin/4114957 to your computer and use it in GitHub Desktop.
Save marcboivin/4114957 to your computer and use it in GitHub Desktop.
Rip Seasons DVD with handbrake
#!/bin/bash
# copyrights this guy http://ubuntuforums.org/showthread.php?t=1544346
# ripdvd.sh
# input must be:
# - <devicename> (which can be anything lsdvd takes)
# - <outputfolder> where do you want the ripped series
# - <outputname> the base name of the output
# - <startsfrom> where to start counting if you use 0 it starts at 1
# (useful for seasons spanning over multiple disks)
INPUT_DVD=$1
OUTPUT_FOLDER=$2
OUTPUT_NAME=$3
STARTS_FROM=$4
LSDVDOUTPUT=$(lsdvd "$1")
# if available get the title and get the number of titles
TITLE=$(echo "$LSDVDOUTPUT" | grep -i Disc | sed 's/Disc Title: //g')
NOMTITLES=$(echo "$LSDVDOUTPUT" | grep -i Length | wc -l)
echo $NOMTITLES
# iterate over each title
for (( c=1; c <= $NOMTITLES+1; c++ )) do
PREFIX=''
# Allows for seasons on multiple DVDs
let n=$c+$STARTS_FROM
if [ $n -lt 10 ]; then PREFIX="0" ; fi
OUTPUT_NAME_TITLE=$OUTPUT_FOLDER"/"$OUTPUT_NAME$PREFIX$n".m4v"
HandBrakeCLI -i $INPUT_DVD -o $OUTPUT_NAME_TITLE -t $c
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment