Skip to content

Instantly share code, notes, and snippets.

@mark-cooper
Created December 11, 2011 20:58
Show Gist options
  • Save mark-cooper/1462701 to your computer and use it in GitHub Desktop.
Save mark-cooper/1462701 to your computer and use it in GitHub Desktop.
Ruby script to convert video files using HandBrakeCLI
# 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