Skip to content

Instantly share code, notes, and snippets.

@cristianrasch
Created October 14, 2010 18:35
Show Gist options
  • Save cristianrasch/626747 to your computer and use it in GitHub Desktop.
Save cristianrasch/626747 to your computer and use it in GitHub Desktop.
dir = ARGV.first || Dir.pwd
Dir.chdir dir unless dir == Dir.pwd
avi_files, srt_files = Dir.glob('*.avi'), Dir.glob('*.srt')
avi_files.each do |avi_file|
md = avi_file.match /s\d+e\d+/i
if md
srt_file = srt_files.find {|srt_file| srt_file =~ Regexp.new(md.to_s, true)}
if srt_file
name = File.basename avi_file, File.extname(avi_file)
File.rename srt_file, name+File.extname(srt_file)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment