Created
May 13, 2016 17:09
-
-
Save bluegraybox/228fc0ab333d2268f16e3b73c0cc2c36 to your computer and use it in GitHub Desktop.
Ruby script to find duplicate files
This file contains 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
#!/usr/bin/ruby -w | |
require 'find' | |
require 'md5' | |
dir = ARGV[0] | |
dir = "." unless dir | |
digests = {} | |
Find.find( dir ) do |f| | |
if File.file?( f ) and File.size?( f ) then | |
d = MD5.file( f ).hexdigest | |
if digests[d] then | |
puts "Duplicates: #{digests[d]} and #{f}" | |
else | |
digests[d] = f | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment