Python script to generate or check md5 checksums recursively for files in a directory tree.
It has been tested for Python versions 2.7, 3.4, and 3.6.
To search recursively for files in a directory and its subdirectories, and check files against their corresponding .md5 checksum files:
md5tool.py check dir1 [dir2, dir3,...]
To generate .md5 checksum files for any files in a directory or its subdirectories which are missing them:
md5tool.py generate dir1 [dir2, dir3,...]
To display a help message to show the usage patterns above:
md5tool.py --help
This script assumes the following naming scheme for the .md5 checksum files
- Each .md5 checksum file is stored in the same directory as the file for which that checksum was calculated.
- Each .md5 checksum file is named the same as the file for which it is calculated, but with an additional ".md5" extension.
- E.g. the checksum for dir1/myfile.mov should be stored in dir1/myfile.mov.md5
-
Download the ZIP archive from github, or clone the repository with git.
-
Place the md5tool.py script somewhere convenient, e.g. a
scripts
directory in your Documents folder. -
Open the Terminal program (in the
Applications/Utilities
directory on your Mac). -
Run the following command in Terminal to set permissions for the script (you only need to do this once).
chmod a+x Documents/scripts/md5tool.py
-
Type the following into Terminal to check files in a directory:
./Documents/scripts/md5tool.py check MYDIRECTORY
- Replace
MYDIRECTORY
with the name of the directory you want to be checked. - To save time, you can drag and drop a directory from the Finder into the terminal window to specify the directory path.
- Windows does not have Python installed by default, so first download and install it from python.org.
- Next, it is necessary to update the Windows PATH variable so that python can be located from the command line.
- Open the Control Panel from the Start Menu and go to:
- System Settings
- Advanced System Settings
- Advanced Tab
- Environmental Settings (extra menu at the bottom)
- Add a new User Variable Path:
C:\Python27
,C:\Python36
, et cetera depending on Python version.- (If you have a different version of Python, adjust the path name accordingly)
-
Download the ZIP archive from github, or clone the repository with git.
-
Place the md5tool.py script somewhere convenient, e.g. a
scripts
directory on yourC:
drive. -
Open the Windows CMD program to get a command line window.
-
Type the following into the command line window to check files in a directory:
python C:\scripts\md5tool.py check MYDIRECTORY
- Replace
MYDIRECTORY
with the name of the directory you want to be checked.