For this I use md5deep, which unlike its name suggests, bundles programs that also do other hashes than MD5.
If you’re on Windows, you can get binaries from the above-mentioned official site, if you’re on Linux, you can probably grab it from your package manager, at least on Ubuntu
apt-get install md5deep does the trick (and – again – it installs all hashing algorithms, not just MD5).
Using it to hash a single file is pretty straightforward, for instance:
md5deep.exe fileToHash.sth > output.txt
> output.txt is used so that the hash is saved to output.txt instead of just being printed on the console)
If you’re on a 64 bits Windows, you’ll want to use something like
md5deep64.exe fileToHash.sth > output.txt
instead. If you’re on Linux, you’ll only have the most appropriate binaries (32 or 64 bits).
For other algorithms, same syntax with different executables, for instance:
sha1deep.exe fileToHash.sth > output.txt
Other executable names: sha256deep, tigerdeep and whirlpooldeep.
Finally, to hash all files in a folder and sub-folders, just use the recursive option:
sha256deep64.exe -r folderToHash > output.txt