0

I want to iteratively add my folders to a zip archive so that all sub-folders are zipped and stored within their parent folder. The following code does not allow me to specify the zip folder path. I would like to have an archive that unzips the contents of the sub-folder.

For example, when 111.zip is opened, it should give me the files shown below in the abc sub-directory. And this should happen the same way for all files in the rec sub-directory, etc.

 import shutil
 shutil.make_archive("111","zip",'/home/user/rec/abc')
Sean Mickey
  • 7,618
  • 2
  • 32
  • 58
Aliya
  • 31
  • 2
  • 9
  • 1
    possible duplicate of [How to create a zip archive of a directory](http://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory) – Andy Mar 25 '15 at 15:39
  • What didn't work? `"/home/usr/rec/abc"` is the zip folder path and it should hold everything under that folder. Are you having problems getting the file list programatically instead of hard coded? – tdelaney Mar 25 '15 at 15:54
  • @Andy - `shutil.make_archive` should work here... how is `zipfile` any better? – tdelaney Mar 25 '15 at 15:55

0 Answers0