add index builder script

This commit is contained in:
Cordelya Sharpe 2023-12-21 14:54:59 -05:00
parent 95449e548f
commit 19177ede1e

35
build-index.sh Executable file
View File

@ -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