Skip to content

Instantly share code, notes, and snippets.

@skyline75489
Created September 8, 2016 13:25
Show Gist options
  • Save skyline75489/3fb8b2891121318b8e2592509650d1b4 to your computer and use it in GitHub Desktop.
Save skyline75489/3fb8b2891121318b8e2592509650d1b4 to your computer and use it in GitHub Desktop.
zip dir using python
def zipdir(path, dirname, archive):
paths = os.listdir(path)
for p in paths:
f = os.path.join(path, p)
if os.path.isdir(f): # Recursive
zipdir(f, os.path.sep.join([dirname, p]), archive)
else:
archive.write(f, os.path.sep.join([dirname, p]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment