It's very simple test to see if the directory exists or not. See the directory test in bash below:
if [ -d /home/mydir ]; then
echo "my directory exists"
fi
bash, directory, existsit, mydir, echo, quot, fi,