CTAN has a new package: texdirflatten