| Store | Cart

Zippping a directory recursively from Python script on Windows

From: Larry Bates <lba...@swamisoft.com>
Thu, 11 Mar 2004 08:46:18 -0600
Max,

You must use os.path.walk() along with zipfile to get
what you want.  os.walk will walk the directory
tree recursively calling a function that you pass
to it.  Inside of that function you can call zipfile
to add each file in that subdirectory to the .ZIP
output file.

-Larry


"Max M" <maxm at mxm.dk> wrote in message
news:404f0141$0$183$edfadb0f at dread12.news.tele.dk...
> I guess that the best approach is calling a shell tool with something> like os.popen(). But I cannot seem to find any free tools.>> Winzip has a command line option, but for registered users only. That is> bothersome if I want to install the script on other machines.>> The same for pkwares zip. At least I cannot seem to find a free version> of it.>> gzip seems able to do the trick, but I need to install Cygwin, that's> also a bother ;-)>> Can it really be that there is no free .zip command line tool for> Windows, or are my Googling skills just to poor?>> Ideally it should just be a single .exe file that I can put in the> folder with my script, for easy distribution.>> Or is there a more Pythonic approach?>>> regards Max M

Recent Messages in this Thread
Max M Mar 10, 2004 11:51 am
Gerrit Muller Mar 10, 2004 11:55 am
Piet van Oostrum Mar 10, 2004 12:52 pm
Max M Mar 10, 2004 12:56 pm
Mike C. Fletcher Mar 10, 2004 01:00 pm
Max M Mar 10, 2004 01:22 pm
Larry Bates Mar 11, 2004 02:46 pm
Max M Mar 11, 2004 08:54 am
Messages in this thread