Skip to content
Advertisement

How can I extract multiple .zip files?

I’m trying to extract multiple files from some .zip archives. My code is:

JavaScript

However, it only extracts the files inside the first archive. I’m using Python 3.6. What is wrong?

Advertisement

Answer

I thought this scenario might be a serious candidate …

What happens is that for each .zip file, all its members are extracted, but they overwrite the ones extracted from the previous file (well, except the 1st). So, at the end, you end up with the files from the last archive that was enumerated.
To get past this issue, you should unzip each .zip file members in a separate directory (the .zip file name).

Below is an example (I also simplified / cleaned your code a bit).

code00.py:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement