Skip to content

Instantly share code, notes, and snippets.

@raullenchai
Created November 28, 2012 20:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raullenchai/4164344 to your computer and use it in GitHub Desktop.
Save raullenchai/4164344 to your computer and use it in GitHub Desktop.
Compare the lay out of dir1 and dir2, ignore the content of files
import os
def compare_dir_layout(dir1, dir2):
def _compare_dir_layout(dir1, dir2):
for (dirpath, dirnames, filenames) in os.walk(dir1):
for filename in filenames:
relative_path = dirpath.replace(dir1, "")
if os.path.exists( dir2 + relative_path + '\\' + filename) == False:
print relative_path, filename
return
print 'files in "' + dir1 + '" but not in "' + dir2 +'"'
_compare_dir_layout(dir1, dir2)
print 'files in "' + dir2 + '" but not in "' + dir1 +'"'
_compare_dir_layout(dir2, dir1)
compare_dir_layout('xxx', 'yyy')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment