Python code to search for all the zip files in the directory and unzip them.
Before
# Program to fetch all the zip files and unzip themimport os,zipfile, pathlibpath_dir = 'F:/ck'entries = pathlib.Path(path_dir)files_present_dir = []for entry in entries.iterdir():files_present_dir.append(entry.name)
#print(*files_present_dir,sep="\n")
l = len(files_present_dir)for check_file in range(0,l):temp = files_present_dir[check_file]if temp.find('.zip') != -1:s = path_dir + '/' + tempwith zipfile.ZipFile((s), 'r') as zip:zip.printdir() #List all the files present in zipprint('Extracting all the files...')zip.extractall(path='F:/ck')print('Done!!')__author__ = "Hemant Kumar Chauhan"
Comments
Post a Comment