python-scripts/18_zipper.py
Michael Herman 63b3354282 added zipper
2014-08-16 17:23:00 -05:00

21 lines
487 B
Python
Executable File

import os
from datetime import datetime
from zipfile import ZipFile
#set file name and time of creation
today = datetime.now()
file_name = 'zipper_' + today.strftime('%Y.%m.%dh%H%M') + '.zip'
dir_name = 'tmp/' # update path
def zipdir(path, zip):
for root, dirs, files in os.walk(path):
for file in files:
zip.write(os.path.join(root, file))
if __name__ == '__main__':
zipfile = ZipFile(file_name, 'w')
zipdir(dir_name, zipfile)
zipfile.close()