question: How can I put empty directories into a zip-archive?

T

T. Kaufmann

Hi there,

in my directory are some 'normal' files like *.py sources and some empty
directories too. How can I put all togehter into a zip-archive?

There is no problem to zip the *.py files but if I try to add empty directories
an exception is trown.

Thanks.

o-o

Thomas
 
C

Christos TZOTZIOY Georgiou

Hi there,

in my directory are some 'normal' files like *.py sources and some empty
directories too. How can I put all togehter into a zip-archive?

There is no problem to zip the *.py files but if I try to add empty directories
an exception is trown.

This is not a direct reply to your problem, but just my 2 eurocents of
information gathered the last five minutes.

Creating a zip file with an external program, one can see that the zip
format seems to include directories, empty and non-empty (or so the
zipfile module helps us discover, when reading the externally created
zip file).
The only difference I found out so far is that the external_attr is
2172649504L (0x81800020) for files and 1103101968 (0x41c00010) for
directories. Perhaps it's a bug in the zipinfo module, but I can't
check SF at the moment.

z= zipfile.ZipFile("c:/temp/ax.zip")
for fi in z.infolist():
print fi.filename, fi.external_attr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top