Re: Writing Empty folders into ZipFile

Discussion in 'Python' started by Christian Heimes, Jun 3, 2008.

  1. schrieb:
    > Hello.
    >
    > I'm having situation writing folders structure into
    > a zip file. Folders contain no files.
    >
    > Is it possible to do in python ?


    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
    Christian Heimes, Jun 3, 2008
    #1
    1. Advertising

  2. Christian Heimes

    MRAB Guest

    On Jun 3, 10:03 am, Christian Heimes <> wrote:
    > schrieb:
    >
    > > Hello.

    >
    > > I'm having situation writing folders structure into
    > > a zip file. Folders contain no files.

    >
    > > Is it possible to do in python ?

    >
    > 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.
    >

    Zip files don't actually support folders; it's just that by convention
    slashes ('/') are used in the names to represent the folder hierarchy,
    eg. "a/b" is taken to mean file "b" in subfolder "a". I've found from
    experience that you can represent an empty folder with an empty file
    whose name ends with '/'.
    MRAB, Jun 3, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tung Wai Yip

    add empty directory using zipfile?

    Tung Wai Yip, Jun 25, 2003, in forum: Python
    Replies:
    6
    Views:
    5,214
    Tung Wai Yip
    Jun 26, 2003
  2. Mark Wondratschek

    Python zipfile: Zip empty directories.

    Mark Wondratschek, Aug 29, 2003, in forum: Python
    Replies:
    2
    Views:
    600
    Mark Wondratschek
    Sep 1, 2003
  3. could ildg
    Replies:
    0
    Views:
    451
    could ildg
    Jul 1, 2005
  4. Jeff Epler
    Replies:
    0
    Views:
    387
    Jeff Epler
    Jul 1, 2005
  5. could ildg
    Replies:
    0
    Views:
    488
    could ildg
    Jul 2, 2005
Loading...

Share This Page