Get the next available id based on the dir names