Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JamesMcMahon
Created March 31, 2018 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesMcMahon/84e6769eed96deb3e28f401fdfbf8b30 to your computer and use it in GitHub Desktop.
Save JamesMcMahon/84e6769eed96deb3e28f401fdfbf8b30 to your computer and use it in GitHub Desktop.
Script to compare just directory names
#!/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