Created
August 20, 2014 11:32
-
-
Save jak/6726fb9081f74342f2c5 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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