More flexible directory parsing