I have a folder (C:\\Python27\\security_camera_snapshot\\)
where image1.png 2.png 3.png .... 100.png
is stored. I need to make them in one.zip file and upload it to a NAS server.
But how can i do the compression of all those files in zip?
I have a folder (C:\\Python27\\security_camera_snapshot\\)
where image1.png 2.png 3.png .... 100.png
is stored. I need to make them in one.zip file and upload it to a NAS server.
But how can i do the compression of all those files in zip?
Just use the zipfile library as in this example adapted for your usage :
#!/usr/bin/env python
import os
import zipfile
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
if __name__ == '__main__':
zipf = zipfile.ZipFile('One.zip', 'w', zipfile.ZIP_DEFLATED)
zipdir('C:\\Python27\\security_camera_snapshot\\', zipf)
zipf.close()