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.
 
 

47 lines
2.0 KiB

#!/bin/bash
# A script which converts plaintext cantos from one canticle to XML formatting.
# Must be run inside canticle directory: [inferno,purgatorio,paradiso]-xml.d
# Tag scripts must be in the above directory.
# 1) word-tags.py --- add <w></w> tags to each word.
# 2) terzina-tags.sh --- add <terzina num="..."> tags to each terzina
# 3) top-level-tags.sh --- add TEI XML header; add <canto> and <terzine> tags
canticles=( 'inferno' 'purgatorio' 'paradiso' )
comedy_xml_dir='../comedy-xml.d'
shell_scripts_dir="$(pwd)"
if [[ "$(pwd)" =~ shell-scripts.d ]]; then
clear
for canticle in "${canticles[@]}";
do
echo "Renaming dirs..."
dir="$canticle-txt.d"
dir_xml="$canticle-xml.d"
echo -e "\n\tMoving $dir to $dir_xml"
mv "$comedy_xml_dir/$dir" "$comedy_xml_dir/$dir_xml"
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 "Changing dir to $shell_scripts_dir" && cd $shell_scripts_dir
done
else
echo "Wrong directory?"
fi