Skip to content

Instantly share code, notes, and snippets.

@listenrightmeow
Last active August 29, 2015 14:01
Show Gist options
  • Save listenrightmeow/37fdb65ea013c020c8a7 to your computer and use it in GitHub Desktop.
Save listenrightmeow/37fdb65ea013c020c8a7 to your computer and use it in GitHub Desktop.
Remove dups with MD5 hashing
require 'digest/md5'
h = {}
Dir.glob("**/*", File::FNM_DOTMATCH).each do |f|
next if File.directory?(f)
k = Digest::MD5.hexdigest(IO.read(f)).to_sym
if h.has_key? k
h[k].push f
else
h[k] = [f]
end
end
h.each_value do |a|
if a.length > 1
puts "*****\n"
a.each { |f| puts f } # File.delete(a[f])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment