Search code examples
python-3.xzippathlib

Unzip all the items from the output of rglob() method using pathlib module


I have a folder that contains zip files in subfolders. I want to unzip all the files using this python code. code shows no error but the files are not extracted can't figure out the problem. Thanks in Advance.

from zipfile import ZipFile
from pathlib import Path


entries = Path('E:\\Bootcamp')
for entry in entries.rglob('*.zip'):
    with ZipFile(entry, 'r') as zip:
        print('Check1')
        zip.extractall()
    print('check2')


Solution

  • The extracted files will be located in the folder where your python file has been saved