Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "digest/md5"
- a = Dir["*"].group_by {|f|
- File.size(f)
- }.select {|k,v| v.size > 1 }.values
- b=a.map{|arr|
- arr.group_by {|v1|
- Digest::MD5.hexdigest(File.read(v1))
- }.select {|h,f| f.size > 1 }.values
- }.map {|x|x[0]}.compact
- c= b.map {|x|x.sort_by{|y| File.mtime(y)}[0..-2]}.flatten
- File.delete(*c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement