Skip to content

Instantly share code, notes, and snippets.

@valtoni
Created November 4, 2017 15:09
Show Gist options
  • Save valtoni/f49d73bbf696227fd0acd6483a68b1c5 to your computer and use it in GitHub Desktop.
Save valtoni/f49d73bbf696227fd0acd6483a68b1c5 to your computer and use it in GitHub Desktop.
Very simple command line zip with python
#!/usr/bin/python
import sys
import os
import zipfile
def main(argv):
zip_file_name = argv[1]
zfi = zipfile.ZipFile(zip_file_name, "w", zipfile.ZIP_DEFLATED)
cur_dir = os.getcwd()
for i in range(2, len(argv)):
filename = argv[i]
absname = os.path.abspath(os.path.join(cur_dir, filename))
zfi.write(absname, filename)
zfi.close()
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment