#!/bin/bash
# Adapted from script by 'Peter van der Does' on website stackoverflow.com
# CC-by-SA
# https://stackoverflow.com/questions/21395159/shell-script-to-create-a-static-html-directory-listing
root="."
echo "
"
DEPTH=1
files="$(find $root -maxdepth $DEPTH)"
for file in $files; do
parentpath="${file#*/}"
parent="${parentpath%/*}"
filename="${file##*/}"
if [[ -z $oldparent ]]; then
echo " - $parent
" && oldparent="$parent"
echo " "
elif [[ $oldparent != $parent ]]; then
echo "
"
echo " - $parent
" && oldparent="$parent"
echo " "
echo "
"