From 19177ede1e5c1d111460be29a40885a2db7f826c Mon Sep 17 00:00:00 2001 From: Cordelya Sharpe Date: Thu, 21 Dec 2023 14:54:59 -0500 Subject: [PATCH] add index builder script --- build-index.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 build-index.sh diff --git a/build-index.sh b/build-index.sh new file mode 100755 index 0000000..c23e96e --- /dev/null +++ b/build-index.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# defin the target dir +parent=$(dirname "${BASH_SOURCE[0]}") +cd $parent; cd ../../../ +directory=$(pwd -P) + +today=`date "+%Y-%m-%d"` + +echo -e "Date: $today\n" + +for dirs in "$directory"/*; do + string="---\n" + area=$(basename "${dirs}") + if [ "$area" != "System Volume Information" ]; then + + string+="title: $area\n" + string+="date: $today\n" + string+="---\n\n" + for cats in "$dirs"/*; do + category=$(basename "${cats}") + string+="# $category\n\n" + for ids in "$cats"/*; do + ident=$(basename "${ids}") + string+="* $ident\n" + done + string+="\n" + done + savedir="$directory/00-09 Index/00 Index/00.01 Index/" + fname="${area:0:5}.md" + fullpath="$savedir$fname" + echo $fullpath + echo -e $string > "$fullpath" + fi +done