Script to run handbrake on an entire folder

UPDATED 8-10-10:
This has been superceeded by its newer version at http://www.surlyjake.com/2010/08/script-to-run-handbrake-recursively-through-a-folder-tree/. The new version features all of the previous features, but can also traverse recursively through a folder structure.

#!/bin/bash
if [ -z "$1" ] ; then
	TRANSCODEDIR="."
else
TRANSCODEDIR="$1"
fi
for file in "$TRANSCODEDIR"/*
do
	HandBrakeCLI -i "${file}" -o "${file}.mp4" --preset="iPhone & iPod Touch"""
done

Save that into a .sh file like “handbrakefolder.sh”

    • Van
    • June 25th, 2010

    Thank you soooooooo much !

    • Dave
    • August 8th, 2010

    This is great, thank you! A technical question though… how would I adjust the shell script so that I can run it in the directory itself and not need to add any arguments;

    ie. cd into Videos and run
    hostname% ~/bin/handbrakefolder.sh

    oh, I renamed the script and placed it in my ~/bin folder, chmod +x ‘ed to make it an executable, so now I can do:

    hostname% cd Videos
    hostname% handbrakefolder .

    Almost perfect ;-)

    • I updated the script to automatically use “.” and process the present directory if no argument is specified.

  1. Thanks for the updated version!!

  1. No trackbacks yet.