Helpful Information
 
 
Category: Python Programming
create zip archive

hi-
i am creating a zip file from a directory. it is working great, but the files in the subdirectories get put into the top level directory in the zip file. I want the directory structure to remain intact when i extract the zip file.
How can I do this? Any ideas? thanks a lot-
Mac

I am using this code, currently:

for name in glob.glob("mypath/*"):
if os.path.isfile(name):
file.write(name, os.path.basename(name), zipfile.ZIP_DEFLATED)

o, i got it. i was using 'basename' without understanding what it meant. i should know better :)










privacy (GDPR)