Download zip_folder.py from kargaranamir/google_fonts: direct link, hf CLI and curl.
- Browser
- Download file 756 Bytes
-
https://huggingface.co/datasets/kargaranamir/google_fonts/resolve/main/zip_folder.py
- Command line
-
hf download hf://datasets/kargaranamir/google_fonts/zip_folder.py
-
curl -L -o zip_folder.py https://huggingface.co/datasets/kargaranamir/google_fonts/resolve/main/zip_folder.py
756 Bytes
| 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.") |