Created
November 4, 2017 15:09
-
-
Save valtoni/f49d73bbf696227fd0acd6483a68b1c5 to your computer and use it in GitHub Desktop.
Very simple command line zip with python
This file contains hidden or 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
| #!/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