Reputation: 8443
Given 2 directories:
dir1
|
+----A
|
+----B
dir2
|
+----A (changed)
|
+----B (no change)
|
+----C (added)
I want to write a python script which will detect and make the following changes:
dir2
to dir1
dir2
to dir1
My idea is to obtain a md5 checksum for all the files. Am I going in the right direction ?
Upvotes: 0
Views: 473
Reputation: 17234
Have a look at the filecmp module.
http://docs.python.org/library/filecmp.html
It also has a function to compare directories.
class filecmp.dircmp(a, b[, ignore[, hide]])
Upvotes: 4
Reputation: 117681
If the files are big then using MD5 checksums is certainly sane.
Make sure to check for the "modified" timestamps to always copy over the newest file.
Upvotes: 1