#1
  1. No Profile Picture
    #-------------------------
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Location
    you s of a
    Posts
    35
    Rep Power
    13

    create zip archive


    hi-
    i am creating a zip file from a directory. it is working great, but the files in the subdirectories get put into the top level directory in the zip file. I want the directory structure to remain intact when i extract the zip file.
    How can I do this? Any ideas? thanks a lot-
    Mac

    I am using this code, currently:

    for name in glob.glob("mypath/*"):
    if os.path.isfile(name):
    file.write(name, os.path.basename(name), zipfile.ZIP_DEFLATED)
  2. #2
  3. No Profile Picture
    #-------------------------
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Location
    you s of a
    Posts
    35
    Rep Power
    13
    o, i got it. i was using 'basename' without understanding what it meant. i should know better

IMN logo majestic logo threadwatch logo seochat tools logo