[Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

Peter Otten __peter__ at web.de
Tue Sep 25 11:26:03 CEST 2012

Gregory Lund wrote:

>     if item.endswith('.zip'):
>         # Combine the base folder name with the subpath to the zip file
>         fullpath = os.path.join(outDir, item)
>         x = zipfile.ZipFile(fullpath,'a')

Why did you change file mode to "a"?

>         x.extractall()
>         x.close()

> I tried to use:
> x.extractall(fullpath) but that of course gave me errors because
> 'fullpath' is the path of the file.
> I need to figure out how to just list the respective Lab_2\aforker,
> Lab_2\allisw99 folders.
> Thus far, I have not had any luck.
> Does python have a way to go back to the relative folder where the zip
> is located?

dest_path = os.path.dirname(fullpath)

More information about the Tutor mailing list