On 2012-11-07, andrea crotti <andrea.crott...@gmail.com> wrote: > Simple problem, given a lot of data in many files/directories, I > should create a tar file splitted in chunks <= a given size. > > The simplest way would be to compress the whole thing and then split. > > At the moment the actual script which I'm replacing is doing a > "system('split..')", which is not that great, so I would like to do it > while compressing. > > So I thought about (in pseudocode) > > while remaining_files: > tar_file.addfile(remaining_files.pop()) > if size(tar_file) >= limit: > close(tar_file) > tar_file = new_tar_file() >
I have not used this module before, but what you seem to be asking about is: TarFile.gettarinfo().size But your algorithm stops after the file is already too big. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list