Re: Removing TDirectory from existing file (to reduce size)

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 06 Sep 2006 23:48:45 +0200


You cannot shrink a ROOT file. You can delete objects and directories. The free space will
be used by the next write operation(s).
You can make a new and smaller file by doing for example

   hadd -f newfile.root oldfile.root

Rene Brun

Seth Zenz wrote:
>
> Hi,
>
> I have an existing root file, which contains a number of TDirectories,
> which in turn have subdirectories and eventually various histograms. I
> need to make the file smaller in size, and as it happens some of the
> directories are unneeded; I would therefore like to remove them from the
> file.
>
> I was able to use the TFile->Delete("directoryname;1") command to remove
> one of the directories. The problem is that, although the directory no
> longer shown in the file when I do ->ls(), the file is the same size on
> disk as before.
>
> Is there a way to shrink the file now that it contains less data? Or,
> alternatively, is there a way to copy only the TDirectories I require
> (with all contents) and write them into a new file?
>
> I'm using root 5.10.00e (the default version for ATLAS software release
> 12.0.2).
>
> Thanks,
> Seth Zenz
>
>
Received on Wed Sep 06 2006 - 23:48:48 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:00 MET