if the output is not a directory and it does not exist then create the directory