Join directories dynamically