Created
December 11, 2011 20:58
-
-
Save mark-cooper/1462701 to your computer and use it in GitHub Desktop.
Ruby script to convert video files using HandBrakeCLI
This file contains hidden or 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
# Ruby script to convert video files using HandBrakeCLI | |
# @path from extension i_ to o_ using preset | |
# Skips processing if output file already exists | |
# http://handbrake.fr/downloads2.php | |
path = 'X:Movies/*' # Change to desired location | |
i_ext = 'mkv' # input file extension | |
o_ext = 'mp4' # output file extension | |
preset = 'iPad' # HandBrake preset | |
Dir[path].each do |file| | |
if file =~ /\.#{i_ext}$/ | |
out = file.gsub(/\.#{i_ext}/, ".#{o_ext}") | |
next if File.exists? out | |
system("HandBrakeCLI.exe -i \"#{file}\" -o \"#{out}\" --preset=\"#{preset}\"") | |
end | |
end | |
# Relax, this may take a while ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment