I know in a bash script I can check for exitance of a directory:
if [ -d "/path/to/dir" ] then echo "Directory /path/to/dir exists."