Last active
December 25, 2015 09:28
-
-
Save campanalbero/6953766 to your computer and use it in GitHub Desktop.
フォルダ内のファイルのMD5を計算して、ハッシュ値とファイル名を記録する。同じハッシュ値(コピーされたファイル)があれば、ファイル名をカンマ区切りで追記する。
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
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