Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Created March 10, 2012 18:13
Show Gist options
  • Save jasonkarns/2012350 to your computer and use it in GitHub Desktop.
Save jasonkarns/2012350 to your computer and use it in GitHub Desktop.
Rename your movie folders.
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