forked from selfire1/BibleGateway-to-Obsidian
-
Notifications
You must be signed in to change notification settings - Fork 7
/
versesplit.sh
28 lines (28 loc) · 874 Bytes
/
versesplit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
source config.sh
for folder in "${translation}"/*/;
do
for file in "${folder}"*.md;
do
filename=${file##*/};
bookchapter="`echo $filename | rev | cut -c4- | rev`"
folderlength=$(expr ${#folder} - 5)
echo "![[${folder}${bookchapter}]]" >> "${folder}/${folder:4:${folderlength}}.md"
echo "$folder$bookchapter.md"
while IFS= read -r line
do
if [[ ${line:0:1} == "v" ]];
then
verse="`grep -o '^v[0-9]*' <<<$line`"
text="`cut -d ' ' -f2- <<<$line`"
num="${verse:1}"
if [ ! -d "$folder$bookchapter" ]; then
mkdir "$folder$bookchapter"
fi
echo "$text" > "$folder$bookchapter/$bookchapter.$num.md"
echo "![[$bookchapter.$num]]" >> "$folder$bookchapter/$bookchapter.md"
fi
done < "$folder$bookchapter.md"
rm "$folder$bookchapter.md"
done;
done;