Skip to content

Instantly share code, notes, and snippets.

@tnq177
Created December 11, 2022 07:33
Show Gist options
  • Save tnq177/c399823c5a1f00acf1751ce139c359bc to your computer and use it in GitHub Desktop.
Save tnq177/c399823c5a1f00acf1751ce139c359bc to your computer and use it in GitHub Desktop.
properly zip a folder to anki apkg
"""
properly zip folder to anki apkg
learned from https://github.com/patarapolw/ankisync2
"""
import sys
from zipfile import ZipFile
from pathlib import Path
if __name__ == "__main__":
indir = sys.argv[1] # path to input dir contains {1...n} files + media + collection.anki2
outfile = sys.argv[2] # apkg
with ZipFile(outfile, "w") as zf:
for f in indir.iterdir():
zf.write(str(f.resolve()), arcname=f.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment