check if directory exists before running cmd ls