4

I have files like this.

md1.gz
md1.gz.md5
md2.gz
md2.gz.md5
....
md300.gz
md300.gz.md

Is there any application (or command line) to check the md5 of all files ?

EDIT: Currently I use cfv from macport. work great without any modification

4 Answers 4

8

The md5 command will check multiple files for you. Simply list all the files you want after the command. I.e. md5 md1.gz md2.gz md3.gz. It will output the md5 hashes like so:

MD5 (md1.gz) = 1c2c02b085a1bc2fed683eca86c0df02
MD5 (md1.gz) = c5515451d8f90a822457a4a8e4bf1791

If you want just the hashes, use the -q flag, it will print only the hash, without the identifying information.

I'm guessing that you want to compare the hash of the files against that in the corresponding .md5 file. You could write a quick shell script to check each generated hash against the one stored in the .md5 file.

Something like this should work:

#!/bin/bash

for file in "$@"; do
  generatedhash=$(md5 -q "$file")
  storedhash=$(< "$file".md5)
  if [[ $generatedhash != $storedhash ]]; then
    echo "Hash for file '$file 'does not match"
  fi
done

Save that to a text file, call it something like checkmd5.sh and do chmod +x checkmd5.sh in the terminal.

It will print out a warning for all files that don't have a matching hash. It prints nothing if the hashes do match. It's quick and dirty, so apologies if it doesn't work for your particular case. But based on the examples you gave, if you run ./checkmd5.sh md*.gz it should check the hashes of the .gz files against the corresponding .md5 files and tell you if any are bad.

2
  • I remember using "something" in linux box to do a hash check with multiple file but I can't remember so I wonder if osx have the same thing.
    – Tg0
    Nov 7, 2011 at 21:35
  • 1
    Glad it's what you're looking for. I added a sample script that should work for you.
    – robmathers
    Nov 7, 2011 at 21:42
2

md5deep is a great cross platform tool to generate and check md5/sha hashes. While it's easy to replicate the recursive hash generation feature in a few lines of shell code, it's not so easy to do that for its hash matching feature.

http://md5deep.sourceforge.net/start-md5deep.html#install

-1

If want to use a gui, you can try with ff_md5drop

-2

Maybe my own product will help you.
fHash https://github.com/sunjw/fhash
An open source files' hash calculator for Windows and Mac OS X.

  • MD5, SHA1, SHA256 and CRC32.
  • Drag & drop.
  • Integrated with context menu in Explorer/Finder.
  • Support multiple files.
4
  • 1
    Please read the Help section on self-promotion & disclosure - apple.stackexchange.com/help/promotion
    – Tetsujin
    Nov 24, 2015 at 11:02
  • @Tetsujin I think this is an answer of the question, why it is "-3"? I just came across this question, and I think fHash which is my own product is useful for this situation. And answers above mine are all just a tool's link. So why you don't flag them?
    – Sun Junwen
    Nov 24, 2015 at 12:01
  • Did you read my link? You need to disclose any affiliation to product.
    – Tetsujin
    Nov 24, 2015 at 12:07
  • In general, answers which show how a specific product can be used to solve the specific problem described in the question tend to get better votes than answers which just link to a product together with a generic text. This is especially valid if you promote your own product.
    – nohillside
    Nov 24, 2015 at 12:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .