diff --git a/.gitignore b/.gitignore index d597474..449fe6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .pyc -.DS_Store \ No newline at end of file +.DS_Store +_tmp \ No newline at end of file diff --git a/18_zipper.py b/18_zipper.py new file mode 100755 index 0000000..a350a70 --- /dev/null +++ b/18_zipper.py @@ -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() diff --git a/_tmp/test_file_01.py b/_tmp/test_file_01.py new file mode 100755 index 0000000..4e64205 --- /dev/null +++ b/_tmp/test_file_01.py @@ -0,0 +1 @@ +fsdfasdfasfasdfasdf \ No newline at end of file diff --git a/_tmp/test_file_02.py b/_tmp/test_file_02.py new file mode 100755 index 0000000..7f1faa3 --- /dev/null +++ b/_tmp/test_file_02.py @@ -0,0 +1 @@ +nasdfafapsodfpaodfk \ No newline at end of file diff --git a/readme.md b/readme.md index c959ab0..894c746 100644 --- a/readme.md +++ b/readme.md @@ -16,4 +16,5 @@ 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. **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) \ No newline at end of file +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 \ No newline at end of file