python unzip all files in directory and subdirectories to same directory code example
Example 1: get all files within multiple directories python
from pathlib import Path
for f in Path().cwd().glob("../*.ext"):
print(f)
Example 2: python extract zip file without directory structure
import os
import shutil
import zipfile
my_dir = r"D:\Download"
my_zip = r"D:\Download\my_file.zip"
with zipfile.ZipFile(my_zip) as zip_file:
for member in zip_file.namelist():
filename = os.path.basename(member)
if not filename:
continue
source = zip_file.open(member)
target = open(os.path.join(my_dir, filename), "wb")
with source, target:
shutil.copyfileobj(source, target)