more robust directory setter (tolerates end / and no end /)