Skip to content

Instantly share code, notes, and snippets.

@wasabi0522
Created April 8, 2011 11:45
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 wasabi0522/909687 to your computer and use it in GitHub Desktop.
Save wasabi0522/909687 to your computer and use it in GitHub Desktop.
#!/bin/env python
# require python 2.x
# usage: zipdir.py <dirname>
import sys
import os
import zipfile
# dirname: archive target
dirname = sys.argv[0]
arcname = dirname + ".zip"
arcfile = zipfile.ZipFile(arcname, "w", zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk(dirname):
for dir in dirs:
arcfile.write(root + "/" + dir)
for file in files:
arcfile.write(root + "/" + file)
arcfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment