Posterous theme by Cory Watilo

Moving sites from windows to linux

I’m helping a friend in his move from windows based hosting to linux based hosting.  One of the big issues so far has been case sensitivity in the linux file system.  After using the tried and true method of clicking until you find a broken link, I came up with a better idea.  Just run this ruby script inside the root directory of your site and it will show you filenames and which files have case issues with it.

#!/usr/bin/ruby
files = Dir['**/**'].sort

files.each do |file|
  #do a case insensitve search first
  all_matches = `ack -lic "#{file}"`.split("\n")
  puts "found #{all_matches.length} matches for #{file}"
  exact_matches = `ack -lc "#{file}"`.split("\n")

  difference = all_matches - exact_matches

  unless difference.empty?
    puts "#{difference.join("\n")}\n\n-----------------------------------------"
  end
end