Create Zip file with no extra folder info

Tony Sideris tonys111 at erols.com
Fri Sep 22 21:34:59 CEST 2000


"Paul Goodyear" <paul at gudge.demon.co.uk> wrote in message
news:rUEy5.12429$g12.952332 at news1.cableinet.net...
> If just created a zip file using
>
> zip = zipfile.ZipFile('c:\\zipfile.zip','w')
>
> zip.write(file)
>
> zip.close()
>
> The zip file is created a okay but I want to be able to create it with no
> folder info.
>
> I get in the path "\\<machine>\<directory>\<directory>\
>
> All I want is nothing to be displayed in the path column.
>
> Please Help
>
> Regards,
>
> Paul Goodyear

looks like zipfile::write takes a second (and third) parameter. the
following accomplished what you want for me:

>>> import zipfile;
>>> z = zipfile.ZipFile('foo.zip', 'w');
>>> z.write('C:/boot.ini', 'anotherFileName.ini');
>>> z.close();
>>> ^Z

-Tony





More information about the Python-list mailing list