Created
November 2, 2010 06:13
-
-
Save manveru/659309 to your computer and use it in GitHub Desktop.
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
# Encoding: BINARY | |
require "digest/md5" | |
abort "usage #$0 path1 [path2] [path3] ..." if ARGV.empty? | |
hashes = Hash.new{|h,k| h[k] = [] } | |
roots = ARGV.map{|arg| File.expand_path(arg) }.uniq | |
roots.each do |root| | |
glob = File.join(root, '/**/*') | |
Dir.glob glob do |path| | |
next unless File.file?(path) | |
puts "Analyzing #{path}" | |
hash = Digest::MD5.hexdigest(File.read(path).encode!) | |
hashes[hash] << path | |
end | |
end | |
hashes.each do |hash, paths| | |
next if paths.size < 2 | |
puts "\nDuplicate files with checksum: #{hash}", *paths | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment