can tarfile maintain directory structure?

David M. Cooke cookedm+news at
Wed Aug 18 21:13:29 CEST 2004

At some point, jaydonnell at (Jay Donnell) wrote:

>> import tarfile
>> tar =, "w:gz")
>> tar.add(directory)
>> tar.close()
>> The add() method is recursive by default. More information and examples
>> here:
> That doesn't maintain the directory structure. When you untar it all
> the files are in the base directory (when I untar it on windows with
> winzip).

Winzip is probably broken? It works for me using GNU tar on Linux.

|David M. Cooke

More information about the Python-list mailing list