Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert contents of current folder to M4V using HandBrakeCLI
#!/bin/bash
#===============================================================================
# FILE: handconv.sh
#
# USAGE: Run manually
#
# DESCRIPTION: Converts the contents of the current folder to M4V using HandBrakeCLI
#
# AUTHOR: Scott Granneman (RSG), scott@websanity.com
# COMPANY: WebSanity
# VERSION: 0.1
# CREATED: 05/31/2013 10:48:32 CDT
# REVISION:
#===============================================================================
# Set IFS to split on newlines, not spaces, but first save old IFS
# See http://unix.stackexchange.com/questions/9496/looping-through-files-with-spaces-in-the-names
SAVEIFS=$IFS
IFS=$'\n'
for i in $(ls *) ; do
# Get the extension of the file, so we can get $filename
extension=${i##*.}
# Get the name of the file, sans extension
filename=$(basename "$i" $extension)
# Encode files with HandBrakeCLI
/Applications/HandBrakeCLI -i "$i" -o ~/Desktop/"$filename"m4v --preset="Normal"
done
# Restore IFS so it’s back to splitting on <space><tab><newline>
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment