Skip to content

Instantly share code, notes, and snippets.

@jak
Created August 20, 2014 11:32
Show Gist options
  • Save jak/6726fb9081f74342f2c5 to your computer and use it in GitHub Desktop.
Save jak/6726fb9081f74342f2c5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fileutils'
def guess_name(name)
md = /([\w\.]+)\.(\d{4})\..*/i.match(name)
moviename = md[1].gsub(/\./, ' ')
year = md[2]
"#{moviename} (#{year})"
end
filename=ARGV[0]
moviename=ARGV[1] || guess_name(filename)
ext=File.extname(filename)
puts "File name: " << filename << " Ext: " << ext
puts "Movie name: " << moviename
STDIN.gets
FileUtils.mkdir moviename
FileUtils.mv filename, "#{moviename}/#{moviename}#{ext}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment