Skip to content

Instantly share code, notes, and snippets.

@JamesMcMahon
Created February 3, 2020 01:01
Show Gist options
  • Save JamesMcMahon/dcfa2495a1fb67a7368912dd4b1be160 to your computer and use it in GitHub Desktop.
Save JamesMcMahon/dcfa2495a1fb67a7368912dd4b1be160 to your computer and use it in GitHub Desktop.
Compare directories script I created for my NAS
#!/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