Created
April 22, 2011 10:16
-
-
Save scturtle/936412 to your computer and use it in GitHub Desktop.
zip downloaded comics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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