Pre-Requisite:
- Python is installed on your machine
- Open IDLE (Python Shell)
- Import os and zipfile. If import fails, then follow this link to install the failed ones in Python.
- Make sure all zipped files are in one folder
- Make sure there is a separate folder where we want our unzipped files to be
In IDLE, type
>>>import os, zipfile
>>>os.getcwd()
'C:\\Program Files\\Python37'
Below command will change the current working directory to the folder where we have placed our zip files.
Note: in Windows, we use double back slashes. Also, in place of ‘xyz’, will be actual user name. OR It can be any folder on any drive.
>>> os.chdir('C:\\Users\\xyz\\Downloads\\zip')
Verify that current working directory is changed
>>>os.getcwd()
'C:\\Users\\xyz\\Downloads\\zip'
Extracting files from Zip files
>>>file=os.listdir()
>>>for i in range(len(file)): (press enter)
unzip=zipfile.ZipFile(file[i]) (press enter)
unzip1=unzip.extractall('C:\\Users\\xyz\\Downloads\\unzip') (Press Enter Twice)
Open the unzip folder to confirm that all the files are extracted from zip files. Enjoy!!!