File size: 1,119 Bytes
1fe7814 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | from __future__ import annotations
import argparse
from pathlib import Path
from zipfile import ZipFile
from tqdm import tqdm
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--zip-dir", default="data/raw/MCFD/chute-zip")
parser.add_argument("--out-dir", default="data/raw/MCFD/extracted")
parser.add_argument("--overwrite", action="store_true")
args = parser.parse_args()
zip_dir = Path(args.zip_dir)
out_dir = Path(args.out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
archives = sorted(zip_dir.glob("chute*.zip"))
if not archives:
raise RuntimeError(f"No MCFD ZIP files found in {zip_dir}")
for archive in tqdm(archives, desc="extract MCFD"):
marker = out_dir / archive.stem / ".extracted"
if marker.exists() and not args.overwrite:
continue
with ZipFile(archive) as zf:
zf.extractall(out_dir)
marker.parent.mkdir(parents=True, exist_ok=True)
marker.touch()
print(f"Extracted {len(archives)} MCFD archives to {out_dir}")
if __name__ == "__main__":
main()
|