Created
March 10, 2012 18:13
-
-
Save jasonkarns/2012350 to your computer and use it in GitHub Desktop.
Rename your movie folders.
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
require 'rubygems' | |
require 'cgi' | |
require 'json' | |
movies = Dir.open(".").select do |f| | |
File.directory?(f) && !f.match(/\..*/) | |
end | |
movies.each do |movie| | |
print "." | |
info = JSON.parse(`curl -s http://www.imdbapi.com/?t=#{CGI.escape(movie)}`) | |
best_name = "#{info['Title']} (#{info['Year']})" | |
unless movie.gsub(/(\S)-/,'\1:') == best_name | |
puts "\n#{movie} should be renamed to: #{best_name}" | |
#File.rename(movie, best_name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment