IF NOT DIR BASH

C++
if [ ! -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY doesn't exist.
fi
Source

Also in C++: