Skip to content

Instantly share code, notes, and snippets.

@jefftriplett
Forked from jbarratt/gist:1343205
Created April 22, 2012 22:51
Show Gist options
  • Save jefftriplett/2467386 to your computer and use it in GitHub Desktop.
Save jefftriplett/2467386 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 "" | /Applications/HandbrakeCLI --preset "AppleTV 2" -i "$FILE" -o "$DST/$MP4"
if [ $? != 0 ]
then
echo "$FILE had problems" >> errors.log
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment