Created
April 8, 2011 11:45
-
-
Save wasabi0522/909687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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