HandbrakeCLI is the command-line version of Handbrake, a popular (and free) video encoding software for OSX. Place this script in a bin directory and run it inside a folder that has files that all need to be converted.
BASH Script
1 2 3 4 5 |
#!/bin/bash for file in `ls -1` ; do /Applications/HandBrakeCLI -i $file -o $file.m4v --preset="iPhone & iPod Touch" done |
Enumerating Filenames
1 2 3 4 5 6 7 8 9 10 11 12 |
#!/bin/bash total=1 for file in `ls -1` ; do if [ $total -lt 10 ] ; then /Applications/HandBrakeCLI -i $file -o ${1}0${total}.mp4 --preset="iPhone & iPod Touch" else /Applications/HandBrakeCLI -i $file -o ${1}${total}.mp4 --preset="iPhone & iPod Touch" fi total=$(($total + 1)) done |
Example
/dir/with/files$/usr/bin/handbrake-dir2iPhone.sh filename