Skip to content

Instantly share code, notes, and snippets.

@fbehrens
Created January 12, 2011 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbehrens/775752 to your computer and use it in GitHub Desktop.
Save fbehrens/775752 to your computer and use it in GitHub Desktop.
iterates over files and delete dublicates
require 'digest/md5'
require 'fileutils'
hash = {}
["/Users/frankbehrens/Desktop/niels\ backup/Pictures/iPhoto\ Library/Originals/**/*.*","**/*.*"].each do |dir|
Dir.glob(dir).each do |file|
print '.'
digest = Digest::MD5.hexdigest(File.read(file))
if hash[digest]
puts "#{file}is dublicate"
FileUtils.rm file
end
hash[digest ] = file
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment