Skip to content

Instantly share code, notes, and snippets.

@redpoint13
Created July 1, 2019 11:38
Show Gist options
  • Save redpoint13/7708af4f6bacac1c129b7ecbcd6643aa to your computer and use it in GitHub Desktop.
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:
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)
@redpoint13
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment