DEV Community

loading...

How to unzip multiple zip files in a folder using python?

abbazs profile image abbazs ・1 min read
import zipfile
from pathlib import Path
p = Path('.')
for f in p.glob('*.zip'):
    with zipfile.ZipFile(f, 'r') as archive:
        archive.extractall(path=f'./{f.stem}')
        print(f'Done {f.stem}')
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide