handle hierarchical dirs