Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created April 22, 2011 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scturtle/936412 to your computer and use it in GitHub Desktop.
Save scturtle/936412 to your computer and use it in GitHub Desktop.
zip downloaded comics
# coding: utf-8
import os,sys,zipfile
def walkdir(d):
l=os.listdir(d)
nodir=True
for t in l:
p=os.path.join(d,t)
if os.path.isdir(p):
nodir=False
walkdir(p)
if nodir:
fn=d+'.zip'
if os.path.exists(fn):
print 'Skip:',os.path.basename(fn)
break
z=zipfile.ZipFile(fn,'w')
print 'Get:',os.path.basename(fn)
for t in l:
p=os.path.join(d,t)
z.write(p)
z.close()
walkdir(os.path.abspath('.'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment