40 lines
945 B
Python
40 lines
945 B
Python
from pathlib import Path
|
|
import zipfile
|
|
|
|
SRC = Path(r"D:\medicusbackup\MEDICUS_2026-01-24_17-07-44.fbk")
|
|
DST = SRC.with_suffix(".zip")
|
|
|
|
total = SRC.stat().st_size
|
|
processed = 0
|
|
chunk = 8 * 1024 * 1024 # 8 MB
|
|
|
|
with zipfile.ZipFile(
|
|
DST,
|
|
"w",
|
|
compression=zipfile.ZIP_DEFLATED,
|
|
compresslevel=9,
|
|
) as zf:
|
|
|
|
zi = zipfile.ZipInfo(SRC.name)
|
|
zi.compress_type = zipfile.ZIP_DEFLATED
|
|
|
|
# ⬇⬇⬇ DŮLEŽITÉ ⬇⬇⬇
|
|
with zf.open(zi, "w", force_zip64=True) as z:
|
|
with open(SRC, "rb") as f:
|
|
while True:
|
|
buf = f.read(chunk)
|
|
if not buf:
|
|
break
|
|
|
|
z.write(buf)
|
|
processed += len(buf)
|
|
|
|
pct = processed * 100 / total
|
|
print(
|
|
f"\rZIP: {pct:6.2f}% ({processed//1024//1024} MB)",
|
|
end="",
|
|
flush=True,
|
|
)
|
|
|
|
print("\nHotovo.")
|