Advertisement
Guest User

Untitled

a guest
Jul 14th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.32 KB | None | 0 0
  1. require "digest/md5"
  2.  
  3. a = Dir["*"].group_by {|f|
  4.     File.size(f)
  5. }.select {|k,v| v.size > 1 }.values
  6.  
  7. b=a.map{|arr|
  8.  arr.group_by {|v1|
  9.   Digest::MD5.hexdigest(File.read(v1))
  10.  }.select {|h,f| f.size > 1 }.values
  11. }.map {|x|x[0]}.compact
  12.  
  13.  
  14. c= b.map {|x|x.sort_by{|y| File.mtime(y)}[0..-2]}.flatten
  15.  
  16. File.delete(*c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement