This Java program creates an MD5 database of all files in a directory structure, and then allows you to easily recheck the contents of the directory and notify you if any files has changed. It does not (currently) detect removed files. It only computes MD5 sum if the "last modified" timestamp of the file has changed since the last run, unless the -nomtime option is used.
(Using the "md5.bat" script)
C:\md5itest>echo foobar > c:\tmp\foobar C:\md5itest>md5i -scan c:\tmp C:\md5itest>md5i -check c:\tmp C:\md5itest>echo gazonk > c:\tmp\foobar C:\md5itest>md5i -check c:\tmp [NOT OK] c:\tmp\foobar Old MD5: 5e963b88334c3c4487572cce68496989 New MD5: 4fec417bec4554de6c345df96b084e96 Old timestamp: Wed Dec 22 13:04:49 CET 2004 New timestamp: Wed Dec 22 13:05:35 CET 2004 Action: I=ignore, U=update database (default: I)? u C:\md5itest>md5i -check c:\tmp C:\md5itest>
md5i [-db <file>] [-v] [-nomtime] [[-updatedb] -scan <dir>] [[-alwaysignore] -check] Generic options: -db FILE uses FILE to store file data (default: ~/.md5database) -v verbose: outputs progress information -nomtime ignore file timestamps Scan options: -scan DIR scans DIR and all sub-directories -updatedb updates the database instead of creating a new Check uptions -check DIR checks all files in DIR and its sub-directories -alwaysignore Don't prompt on modified files: only report and ignore
A file containing the compiled Java code and Windows and Unix
wrapper scripts can be downloaded here:
The source can be downloaded here: md5i-src-20041222.tar
The file md5i is the Unix wrapper script and md5i.bat is for Windows. The Unix shell script checks for $JAVA_HOME while the Windows batch file assumes that the java.exe executable is in your %PATH%. Also, on Unix you'll have to "chmod +x md5i" first and if you want to be able to run it from other locations, you'll have to edit the script to set JARPATH to the location of the md5i.jar file. The program will always exit with a non-zero exit code if any files has been modified.
The good thing about commuting by train is that you basically
have a lot of time that you spend being very bored. And boredom
fosters creativity. Sort of. So during the trip home from
Stockholm, I hacked this extremely bare-bones GUI for MD5i. I
have only made a Java Web Start package of it, so far. As with
my other GUI applications, it works on Windows and probably
Linux. Launch it by clicking the link below:
To use, first chose a folder and then click "Build database". On
subsequent runs, you click "Check" to check if the folder
contents has changed.
Screenshots: main dialog, notification that a file has been changed.
Many, I'm sure. No warranties, yada yada.
Rasmus Sten created this after a suggestion from Santeri. There are many other improvements that can be done. For example, the use of a faster MD5 implementation (as in Duper) would speed up things considerably. The code is free to do whatever you want with. If you want to build a GUI, check out the main() method on the MD5Integrity class, which demonstrates what has to be done.