can tarfile maintain directory structure?

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


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

>> import tarfile
>> 
>> tar = tarfile.open(filename, "w:gz")
>> tar.add(directory)
>> tar.close()
>> 
>> The add() method is recursive by default. More information and examples
>> here: http://docs.python.org/lib/module-tarfile.html
>
> 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
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list