Skip to content

Instantly share code, notes, and snippets.

@campanalbero
Last active December 25, 2015 09:28
Show Gist options
  • Save campanalbero/6953766 to your computer and use it in GitHub Desktop.
Save campanalbero/6953766 to your computer and use it in GitHub Desktop.
フォルダ内のファイルのMD5を計算して、ハッシュ値とファイル名を記録する。同じハッシュ値(コピーされたファイル)があれば、ファイル名をカンマ区切りで追記する。
require 'digest/md5'
hash = Hash.new {}
Dir.glob('*') do |f|
digest = Digest::MD5.file(f).to_s
if hash[digest] == nil then
hash.store(digest, f)
else
hash.store(digest, hash[digest] + ", " + f)
end
end
hash.keys.each{|k|
puts k + ", " + hash[k]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment