Skip to content

Instantly share code, notes, and snippets.

@joshcarter
Created October 25, 2012 22:48
Show Gist options
  • Save joshcarter/3955952 to your computer and use it in GitHub Desktop.
Save joshcarter/3955952 to your computer and use it in GitHub Desktop.
Checksum directory of DVD images
def each_file(root, &block)
Dir.foreach(root) do |entry|
next if entry.start_with?(".")
entry = File.join(root, entry)
if File.file?(entry)
block.call(entry)
else
each_file(entry, &block)
end
end
nil
end
Dir.foreach(".") do |entry|
next unless entry.end_with?(".dvdmedia")
sum = ""
each_file(entry) do |file|
sum << IO.popen("shasum \"#{file}\"").read.split.first
end
puts "#{entry} => #{sum.hash}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment