Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import os
  2.  
  3.  
  4. def main():
  5.  
  6.  
  7. print('*** Create a zip file from multiple files using with ')
  8.  
  9. # Name of the Directory to be zipped
  10. dirName = '/var/www/convert4k.com/'
  11.  
  12. # create a ZipFile object
  13. with ZipFile('sampleDir.zip', 'w') as zipObj:
  14. # Iterate over all the files in directory
  15. for folderName, subfolders, filenames in os.walk(dirName):
  16. for filename in filenames:
  17. #create complete filepath of file in directory
  18. filePath = os.path.join(folderName, filename)
  19. # Add file to zip
  20. zipObj.write(filePath)
  21.  
  22.  
  23. if __name__ == '__main__':
  24. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement