You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
2.2 KiB

#!/bin/bash
# A script which converts plaintext cantos from one canticle to XML formatting.
canticles=( 'inferno' 'purgatorio' 'paradiso' )
comedy_xml_dir=../comedy-xml.d
comedy_xml_dir_bak=../comedy-xml.d.bak
comedy_plaintext_dir=../comedy-plaintext.d
shell_scripts_dir="$(pwd)"
if [[ "$(pwd)" =~ shell-scripts.d ]]; then
clear
if [[ ! -d "$comedy_xml_dir" ]]; then
echo 'Making `comedy-xml.d`'
mkdir $comedy_xml_dir
else
echo 'Moving your `../comedy-xml.d/` to `../comedy-xml.d.bak`'
mv $comedy_xml_dir $comedy_xml_dir_bak && mkdir $comedy_xml_dir
fi
for canticle in "${canticles[@]}";
do
echo -e "\nRenaming dirs..."
dir="$canticle-txt.d"
dir_xml="$canticle-xml.d"
if [[ -d $comedy_plaintext_dir ]]; then
echo -e "\tMoving $dir to $dir_xml"
cp -r "$comedy_plaintext_dir/$dir" "$comedy_xml_dir/$dir_xml"
else
echo "Could not find dir: $comedy_plaintext_dir"
fi
done
for canticle in "${canticles[@]}";
do
dir_xml="$comedy_xml_dir/$canticle-xml.d"
echo "Copying word-tags.py" && cp ../py-scripts.d/word-tags.py $dir_xml/word-tags.py &&\
echo "Changing dir to $dir_xml" && cd $dir_xml &&\
echo "Running word-tags.py" && python3 word-tags.py &&\
echo "Removing word-tags.py" && rm word-tags.py &&\
echo "Changing dir to $shell_scripts_dir" && cd $shell_scripts_dir &&\
echo "Copying tercet-tags.sh" && cp ../shell-scripts.d/tercet-tags.sh $dir_xml/tercet-tags.sh &&\
echo "Changing dir to $dir_xml" && cd $dir_xml &&\
echo "Running tercet-tags.sh" && ./tercet-tags.sh &&\
echo "Removing tercet-tags.sh" && rm tercet-tags.sh &&\
echo "Changing dir to $shell_scripts_dir" && cd $shell_scripts_dir &&\
echo "Copying top-level-tags.sh" && cp ../shell-scripts.d/top-level-tags.sh $dir_xml/top-level-tags.sh &&\
echo "Changing dir to $dir_xml" && cd $dir_xml &&\
echo "Running top-level-tags.sh" && ./top-level-tags.sh &&\
echo "Removing top-level-tags.sh" && rm top-level-tags.sh &&\
echo "Adding .gitignore" && echo 'xpath.sh' > .gitignore &&\
echo "Changing dir to $shell_scripts_dir" && cd $shell_scripts_dir
done
else
echo "Wrong directory?"
fi