File size: 756 Bytes
8c50d4f | 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 | import os
import zipfile
from pathlib import Path
# Root folder containing ISO script directories
SOURCE_DIR = Path("fonts_data")
# Where the zip files will be stored
OUTPUT_DIR = Path("zipped_fonts")
OUTPUT_DIR.mkdir(exist_ok=True)
for script_dir in SOURCE_DIR.iterdir():
if script_dir.is_dir():
zip_path = OUTPUT_DIR / f"{script_dir.name}.zip"
print(f"Zipping {script_dir.name} -> {zip_path}")
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
for file in script_dir.rglob("*"):
if file.is_file():
# keep relative structure inside zip
arcname = file.relative_to(SOURCE_DIR)
zipf.write(file, arcname)
print("Done.") |