Skip to content

Instantly share code, notes, and snippets.

@dev01d
Last active November 14, 2018 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dev01d/3fbd34b3e27838adb5d486d58cec6b04 to your computer and use it in GitHub Desktop.
Save dev01d/3fbd34b3e27838adb5d486d58cec6b04 to your computer and use it in GitHub Desktop.
This script automatically converts a directory of video files to H.265 HEVC with HandBrake and deletes the old files.
#!/bin/bash
#
# This script automatically converts a directory of video files to H.265 HEVC with HandBrake and deletes the old files.
#
if [ -z "$1" ]; then
SRC="."
else
SRC="$HOME/$1"
fi
find "$SRC" -iregex '.*\.\(mkv\|avi\)$' -exec bash -c 'HandBrakeCLI -i "$1" -o "${1%\.*}".mp4 -e x265 -q 22 -E av_aac --custom-anamorphic --keep-display-aspect' __ {} \; && find "$SRC" -iregex '.*\.\(mkv\|avi\)$' -exec rm -r {} \;
#
## Desktop notification
#
unameNote="$(uname -s)"
case "${unameNote}" in
Linux*)
notify-send "Encode complete."
;;
Darwin*)
osascript -e 'display notification "Encode complete." with title "HEVC Conversion"'
;;
*)
machine = "UNKNOWN:${unameOut}"
esac
echo ${desktopNotify}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment