Add file to zip, or replace file in zip
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Add file to zip, or replace file in zip

From: abcd <codecraig@gmail.com>
Date: Fri Apr 28 2006 - 14:11:21 CEST

I have a script which zips up a directory, once it does with that
(before it closes the zip file) I want to replace a file that was added
to the zip, say "Foo.txt".

So I tried this...
[code]
z = zipfile.ZipFile("blah.zip", "w")
# zip the directory
#...
z.writestr("c:\\path\\to\\current\\foo_txt_file\\Foo.txt", "some new
data")
z.close()

All this does is add a new Foo.txt file in the zip alongside the
existing one....any suggestions?

Thanks
Received on Mon May 1 00:37:14 2006