Reputation: 175
I have a large amount of zipped files in a single directory that I would like to decompress and save them to the same directory and with the same name as the zipped file.
Upvotes: 1
Views: 4962
Reputation: 77329
Start with something like:
import glob
import os
import zipfile
zip_files = glob.glob('*.zip')
for zip_filename in zip_files:
dir_name = os.path.splitext(zip_filename)[0]
os.mkdir(dir_name)
zip_handler = zipfile.ZipFile(zip_filename, "r")
zip_handler.extractall(dir_name)
Sorry, I don't have time to test this code; any bug is left as an exercise for you.
[Updated with eumiro's suggestion]
Upvotes: 3