Created
July 1, 2019 11:38
-
-
Save redpoint13/7708af4f6bacac1c129b7ecbcd6643aa to your computer and use it in GitHub Desktop.
snippet goes through two folders recursively and displays all files that have the same name, but are different and it lists all files that exist either on the left or right filepath:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import filecmp | |
c = filecmp.dircmp(filepath1, filepath2) | |
def report_recursive(dcmp): | |
for name in dcmp.diff_files: | |
print("DIFF file %s found in %s and %s" % (name, | |
dcmp.left, dcmp.right)) | |
for name in dcmp.left_only: | |
print("ONLY LEFT file %s found in %s" % (name, dcmp.left)) | |
for name in dcmp.right_only: | |
print("ONLY RIGHT file %s found in %s" % (name, dcmp.right)) | |
for sub_dcmp in dcmp.subdirs.values(): | |
print_diff_files(sub_dcmp) | |
report_recursive(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source & thank you: https://janakiev.com/til/python-filecmp/