| Store | Cart

Zippping a directory recursively from Python script on Windows

From: Max M <m...@mxm.dk>
Thu, 11 Mar 2004 09:54:04 +0100
Mike C. Fletcher wrote:

> Max M wrote:>> Honestly, I wouldn't do this myself, I just tell everyone to get tar and > gzip, but here's a simple example of using ZipFile for creating zips of > directories.  You'd want to check for .jpg, .mpg, etceteras and avoid > compressing those most likely, but the basics are there.

Ok I got around to trying out the tarfile module, and as usual it was 
far easier than I would have suspected.

import tarfile

package = 'somedir'
tf = tarfile.open('%s.tar.gz' % package, 'w:gz')

So much for using command line tools for this... ;-)

Thanks for all the pointers.

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