Zippping a directory recursively from Python script on Windows
Max M
maxm at mxm.dk
Thu Mar 11 03:54:04 EST 2004
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')
tf.add(package)
tf.close()
So much for using command line tools for this... ;-)
Thanks for all the pointers.
regards Max M
More information about the Python-list
mailing list