Created
August 11, 2014 18:52
-
-
Save rsgranne/aa07d7864ea0bd47ae01 to your computer and use it in GitHub Desktop.
Convert contents of current folder to M4V using HandBrakeCLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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