can tarfile maintain directory structure?

Adonis adonisv at DELETETHISTEXTearthlink.net
Tue Aug 17 21:05:59 EDT 2004


"Jay Donnell" <jaydonnell at yahoo.com> wrote in message
news:a6fdfd6b.0408171508.65d670d0 at posting.google.com...
> Is there a way to use the tarfile module to recursively compress the
> contents of a directory and maintain the directory structure in the
> tar archive?
>
> Simply doing os.system('tar -czvf ' + fileName +'.tar.gz ' +
> directory)
>  works great on linux, but I need this script to work on windows as
> well :(

Starting from Python 2.3 there is a tarfile module in the stdlib
http://docs.python.org/lib/module-tarfile.html

Adonis





More information about the Python-list mailing list