added zipper
This commit is contained in:
parent
e8379b69cc
commit
63b3354282
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.pyc
|
||||
.DS_Store
|
||||
_tmp
|
20
18_zipper.py
Executable file
20
18_zipper.py
Executable file
@ -0,0 +1,20 @@
|
||||
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()
|
1
_tmp/test_file_01.py
Executable file
1
_tmp/test_file_01.py
Executable file
@ -0,0 +1 @@
|
||||
fsdfasdfasfasdfasdf
|
1
_tmp/test_file_02.py
Executable file
1
_tmp/test_file_02.py
Executable file
@ -0,0 +1 @@
|
||||
nasdfafapsodfpaodfk
|
@ -17,3 +17,4 @@
|
||||
1. **15_check_my_environment.py**: Pass in a config file based on your environment.
|
||||
1. **16_jinja_quick_load.py**: Render a quick Jinja2 template
|
||||
1. **17_rewrite_git_history.md**: Backdating/Rewriting Git history (use at your own risk)
|
||||
1. **18_zipper.py**: Zip contents of a directory, adding a timestamp to the filename
|
Loading…
Reference in New Issue
Block a user