So I\'m creating a GitHub Pages site to list all of the Gifs in my jglovier/gifs repo. GH Pages runs only static HTML/CSS/JS or Jekyll, so I cannot use an apache directory listi
Simple enough with no empty dirs (although can get empty ones at end of script and append them simply anyway)
#!/bin/bash
root="root"
echo ""
for file in "$root"/*/*; 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 " "
fi
echo " - $filename
"
done
echo "
"
echo "
"
e.g.
$ ./abovescript
- accidents
- bears
- cats