Parsimony
[llpp.git] / misc / cbzl.py
blob48a66e99bca6aee8509d91848f55a27da715ccf8
1 #!/usr/bin/env python
2 # based on http://doeidoei.wordpress.com/2010/11/23/compressing-files-with-python-symlink-trouble/
3 import os, sys, zipfile, string
5 if len (sys.argv) < 2:
6 print """\
7 usage: find . -name \*.jpg -or -name \*.png -print0 | python cbzl.py curimgs.cbz
8 or: locate -0 .jpg | python cbzl.py allimgs.cbz
9 """
10 sys.exit (1)
12 with zipfile.ZipFile (sys.argv[1], "w") as z:
13 zerosep = sys.stdin.read ()
14 files = string.split (zerosep, '\0')
15 for name in files:
16 a = zipfile.ZipInfo ()
17 a.filename = os.path.basename (name)
18 a.create_system = 3
19 a.external_attr = 2716663808L
20 z.writestr (a, name)