Created
October 30, 2017 13:37
-
-
Save tadone/be55f2b3b42013fd7bfc381a408d0744 to your computer and use it in GitHub Desktop.
[Zip dir function w/ exclude dirs] Zip up directory excluding some dirs #python
This file contains 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
exclude = ['dir1','dir2'] | |
def zipdir(path, ziph, exclude): | |
'''Zip up the directory excluding some subdirs''' | |
# ziph is zipfile handle | |
for dirname, subdirs, files in os.walk(path): | |
subdirs[:] = [d for d in subdirs if d not in exclude] | |
for file in files: | |
ziph.write(os.path.join(dirname, file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment