473,804 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Jul 18 '05 #1
2 2216
On Thu, 04 Sep 2003 15:54:57 +0200, rumours say that "T. Kaufmann"
<me****@snafu.d e> might have written:
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_att r
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
Jul 18 '05 #2
T. Kaufmann wrote:
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


Try http://mail.python.org/pipermail/pyt...ne/170517.html

Peter
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
15223
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
2
2975
by: Mark Wondratschek | last post by:
Hi! I hope it's a simple question: How can I pack empty directories? I want to mirror a whole directory structure in an archive. So I want to zip non-empty AND empty directories. Any ideas? Thank you in advance! Best regards Mark
4
1871
by: Peter | last post by:
Hi, Not sure if this is a proper ng to post this question. Is here anybody who has used zlib? I downloaded 1.2.1 of zlib from www.gzip.org/zlib (for windows 98/nt/2000/xp), and used it in my program to zip/unzip files. When I use the zipper class in zlib to zip a folder, I got a zip file with the SAME SIZE of zip file created (on the same folder) with the 'ZipTest' program downloaded from the site. But the problem is that the zip file...
13
33674
by: could ildg | last post by:
I want to check if a folder named "foldername" is empty. I use os.listdir(foldername)== to do this, but it will be very slow if the folder has a lot of sub-files. Is there any efficient ways to do this? Thanks~
3
1353
by: Michael | last post by:
Hello experts! I hope to tap your vast knowledge of unbound wisdom. Please help this humble squire in his search for knowledge. Product: MS Access 2003 I have a report that basically lists the contents of a dB into somewhat a readable format. What I'm trying to do though is not display a field for any record where said field is blank. ie. record1 has zip field blank, thus on report, record1 doesn't
26
2675
by: Jan Engelhardt | last post by:
Hello, assume foo/bar.h exists, and is included as '#include "bar.h"' in foo/bar.c. `gcc -c foo/bar.c` will compile it fine (i.e. finds the file). Is this a gcc extension or a C compiler standard feature that foo/ will be searched without explicitly passing -Ifoo? $ cat foo/bar.h #define GOAL 1
5
2920
by: Jandre | last post by:
Hi I am a python novice and I am trying to write a python script (most of the code is borrowed) to Zip a directory containing some other directories and files. The script zips all the files fine but when it tries to zip one of the directories it fails with the following error: "IOError: Permission denied: 'c:\\aaa\\temp'" The script I am using is:
1
2605
by: Tim Slattery | last post by:
I have a form in which several elements are expected to be all digits. Some of those elements can be left empty, but if specified they must be all digits. I have this Sub to edit them: Sub NumEdit(ByRef Req, ByVal value, ByRef size, ByRef name, ByRef tag) Dim allDigs Set allDigs = new RegExp allDigs.Pattern = "^\d+$" If IsNull(value) Then
4
269
by: thomas1388 | last post by:
I am created a form to display addresses. There are 5 fields, street, street line 2, city , state and zip code. If there is street line 2, it will become my address line 2, City & ", " * state & zip will become my address line 3. Since some of the addresses don't have street line 2, I like to make City & ", " * state & zip as my address line 2, the address line 3 will become invisible. After I binded a dataset in the data source...
1
2363
by: Christian Heimes | last post by:
otaeris@o2.pl schrieb: As far as I remember the zip format it's not possible at all. Folders are created implicitly. The zip format doesn't support empty directories. Christian
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10354
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10101
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.