ckkkkkkk
ckkkkkkk

Reputation: 11

How to unzip many files with python

I got more than 1000 zip files in the same folder with naming convention output_MOJIBAKE

Example name: output_0aa3199eca63522b520ecfe11a4336eb_20210122_181742

How can I unzip them using Python?

Upvotes: 1

Views: 5861

Answers (1)

Ayush Gupta
Ayush Gupta

Reputation: 1227

Try this and let me know if it worked.

import os
import zipfile

path = 'path/to/your/zip/files'

os.chdir(path)

for file in os.listdir('.'):
    with zipfile.ZipFile(file, 'r') as zip_ref:
        zip_ref.extractall('.')

Upvotes: 4

Related Questions