added zipper

This commit is contained in:
Michael Herman 2014-08-16 17:23:00 -05:00
parent e8379b69cc
commit 63b3354282
5 changed files with 26 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
.pyc .pyc
.DS_Store .DS_Store
_tmp

20
18_zipper.py Executable file
View 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
View File

@ -0,0 +1 @@
fsdfasdfasfasdfasdf

1
_tmp/test_file_02.py Executable file
View File

@ -0,0 +1 @@
nasdfafapsodfpaodfk

View File

@ -16,4 +16,5 @@
1. **14_html_to_markdown.sh**: Convert all html files in a single directory to markdown 1. **14_html_to_markdown.sh**: Convert all html files in a single directory to markdown
1. **15_check_my_environment.py**: Pass in a config file based on your environment. 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. **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. **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