creating size-limited tar files

Neil Cerutti neilc at
Wed Nov 7 19:40:14 CET 2012

On 2012-11-07, andrea crotti <andrea.crotti.0 at> 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:


But your algorithm stops after the file is already too big.

Neil Cerutti

More information about the Python-list mailing list