Python zip all files in directory script failed -
Python zip all files in directory script failed -
i want write simple script python zip file in folder. have until now:
import os import zipfile zfname = 'simonszip.zip' foo = zipfile.zipfile(zfname, 'w') dirname, dirnames, filenames in os.walk('.'): # print path filenames. filename in filenames: print (os.path.join(dirname,filename)) foo.write(os.path.join(dirname, filename)) foo.close()
when sudo python script.py
script runs, never ends, while producing enormous zip file.
any ideas?
you're doing recursion. since zip created listed in files. you're writing zip within zip within zip within zip , on.
python
Comments
Post a Comment