Created
February 3, 2020 01:01
-
-
Save JamesMcMahon/dcfa2495a1fb67a7368912dd4b1be160 to your computer and use it in GitHub Desktop.
Compare directories script I created for my NAS
This file contains 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
#!/usr/bin/env python | |
import os | |
import sys | |
def remove_prefix(text, prefix): | |
if text.startswith(prefix): | |
return text[len(prefix):] | |
return text | |
path1 = sys.argv[1] | |
path2 = sys.argv[2] | |
dirs1 = set([remove_prefix(dp, path1) for dp, dn, fn in os.walk(path1)]) | |
dirs2 = set([remove_prefix(dp, path2) for dp, dn, fn in os.walk(path2)]) | |
print('\n'.join(dirs1 - dirs2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment