auto detec directory in output directory