I want to write a function that compares two files / folders to check if one of them is changed.
If there is something added/removed or changed in a file it means that some changes happen in one of them. So the function returns that provided files are not identical. This one is easy.
The hard part (if it is a folder): I want to check if two folders that has same material. For example:
Folder 1:
- testfolder (has a.txt inside)
- testfile.txt
- testfile2.txt
Folder 2:
- testfolder (its a.txt has different text than the other one) – changed
- testfile.txt (same) – no change
- testfile2.txt (same) – no change
Output: Function return that these two folders (Folder 1 and 2) are not the same. (Because testfolder inside Folder 2 has a file that is not identical to the file in testfolder that is inside Folder 1)
How can I create such control, what is the best approach? Should I do a recursive search in all folders and check all files one by one? (Hope not) Is there a MD5 control for folders like files? What should I do?
I think you should do recursive comparision of folder. This should not be difficult.
As was wrote in this question the best approach of file comparison is byte-to-byte comparision. This article shows how to do it.