Skip to content

Instantly share code, notes, and snippets.

@jbarratt
Created November 6, 2011 17:30
Show Gist options
  • Save jbarratt/1343205 to your computer and use it in GitHub Desktop.
Save jbarratt/1343205 to your computer and use it in GitHub Desktop.
Bulk HandbrakeCLI Encoder
#!/bin/bash
find . -name "*.mkv" | while read FILE
do
# What would the output file be?
DST=/Volumes/USBRAID/Converted/$(dirname "$FILE")
MKV=$(basename "$FILE")
MP4=${MKV%%.mkv}.mp4
# If it already exists, don't overwrite it
if [ -e "$DST/$MP4" ]
then
echo "NOT overwriting $DST/$MP4"
else
echo "\"$FILE\" \"$DST/$MP4\""
mkdir -p "$DST"
echo "" | HandbrakeCLI --preset "AppleTV 2" -i "$FILE" -o "$DST/$MP4"
if [ $? != 0 ]
then
echo "$FILE had problems" >> errors.log
fi
fi
done
# test of editing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment