# How many Trees are in a root file?

**URL:** <https://root-forum.cern.ch/t/how-many-trees-are-in-a-root-file/32477>\
**Category:** Newbie\
**Tags:** tree, root\
**Created:** [January 28, 2019, 8:23pm UTC](https://root-forum.cern.ch/t/how-many-trees-are-in-a-root-file/32477 "2019-01-28T20:23:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [January 29, 2019, 4:08am UTC](https://root-forum.cern.ch/t/how-many-trees-are-in-a-root-file/32477/2 "2019-01-29T04:08:51Z")

</div>

Hi,

you can loop on the keys holding objects stored in a ROOT files and get their type name, e.g. “TTree” as follows:

```auto
for (auto&& keyAsObj : file->GetListOfKeys()){
 auto key = (TKey*) keyAsObj;
 cout << key->GetName() << " " << key->GetClassName() << endl;
}

```

if it is enough for you, you can achieve this with a command line utility, rootls

```auto
rootls myfile.root

```

Cheers,  
D

---

_[View the full topic](https://root-forum.cern.ch/t/how-many-trees-are-in-a-root-file/32477)._
