Folder

Exists

Check if a folder exists:

DESTDIR=$HOME/repo/vm/$1/
if [ -d "$DESTDIR" ]; then
    echo Folder $DESTDIR already exists, cannot continue...
    exit
fi
mkdir -p $DESTDIR
if [ ! -d "$DESTDIR" ]; then
    echo Error: Folder $DESTDIR was not created...
    exit
fi

List

ls -1d */

Also see sample/bash/iterate-folders.sh.

Name

From Get current directory name (without full path):

export DJANGO_SETTINGS_MODULE="example_${PWD##*/}.dev_`id -nu`"

# to assign to a variable
result=${PWD##*/}