Feb-09-2020, 12:56 AM
(Feb-08-2020, 11:28 AM)jim2007 Wrote: [ -> ]It is almost certainly an issue with passing the correct file name to the function. Try hard coding one of the file names into the my_zip variable and see if it runs without error.
Thank you, you're correct if I hard code one of the zipfiles into the my_zip variable script works. How do you think I can modify this script so it chooses files from a folder?
Edit: this one works as well if I hard code one of the zipfiles. I would like to iterate on every zipfile and subfolders in that zipfile in order to extract them all into one main folder.
import glob import zipfile import shutil import os my_dir = "/Users/myusernamehere/Documents/My_Dataset/new" my_zip = r"/Users/myusernamehere/Documents/My_Dataset/something.zip" with zipfile.ZipFile(my_zip) as zip: for zip_info in zip.infolist(): if zip_info.filename[-1] == '/': continue zip_info.filename = os.path.basename(zip_info.filename) zip.extract(zip_info, my_dir)