Re: Delete Files with root

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 22 Feb 2006 20:37:11 +0100


Hi Michael,
copy & paste the following onto a bash prompt:

---
cat > deleteBroken.C << EOF
void checkFile(const char* n) {
   TFile* f = new TFile(n);
   Bool_t remove=(!f || f->IsZombie());
   delete f;
   if (remove) printf("Almost called gSystem->Unlink(%s)\n",n);
   //if (remove) gSystem->Unlink(n);
}
void deleteBroken() {
EOF
ls *.root | sed 's,^\(.*\)$,checkFile(\"\1\");,' >> deleteBroken.C
echo '}' >> deleteBroken.C
root -l -b -q deleteBroken.C
---

Instead of sed you can also use TSystem::OpenDirectory() / GetDirEntry() 
/ FreeDirectory() to iterate over files from within ROOT.

Axel.

Michael Kosta Mitrovski wrote:

> Dear rooters,
>
> I produced Simulation files (20000) and some (5000) of them crashed in
> the production (all of them are root-files). Is there a way when I am
> analysing my files which are ok to delete the otherones which crashed???
> Thanks.
>
> Best regards,
>
> Michael
>
Received on Wed Feb 22 2006 - 20:41:32 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET