From 6ef0940881ea075a5df6d01147ebe7ec4f9d8a28 Mon Sep 17 00:00:00 2001 From: Matt Troutman Date: Fri, 27 Sep 2024 11:14:23 -0500 Subject: [PATCH] Iterate over each folder. and also update the .setup_complete bits. --- iterate.sh | 41 +++++++++++++++++++++++++++++++++++++++++ prep 1 font.sh | 10 +++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 iterate.sh diff --git a/iterate.sh b/iterate.sh new file mode 100644 index 0000000..4f4cb93 --- /dev/null +++ b/iterate.sh @@ -0,0 +1,41 @@ +#!/bin/zsh + + + +# Define the absolute path to the prep script +PREP_SCRIPT="$(cd "$(dirname "$0")" && pwd)/prep 1 font.sh" + +# Check if the prep script exists +if [[ ! -f "$PREP_SCRIPT" ]]; then + echo "Prep script not found: $PREP_SCRIPT" + exit 1 +fi + +# Ensure the prep script is executable +chmod u+x "$PREP_SCRIPT" + +# Check if the prep script is executable +if [[ ! -x "$PREP_SCRIPT" ]]; then + echo "Prep script not executable: $PREP_SCRIPT" + exit 1 +fi + +# Define the absolute path to the font_files directory +FONT_FILES_DIR="$(cd "$(dirname "$0")" && pwd)/font_files" + +# Check if the font_files directory exists +if [[ ! -d "$FONT_FILES_DIR" ]]; then + echo "font_files directory not found: $FONT_FILES_DIR" + exit 1 +fi + +# Iterate over each folder in font_files +for folder in "$FONT_FILES_DIR"/*; do + if [[ -d "$folder" ]]; then + cd "$folder" || continue + zsh "$PREP_SCRIPT" + cd .. + else + echo "No such directory: $folder" + fi +done \ No newline at end of file diff --git a/prep 1 font.sh b/prep 1 font.sh index bb87439..1d675d9 100755 --- a/prep 1 font.sh +++ b/prep 1 font.sh @@ -1,5 +1,12 @@ #! /bin/zsh +#if file name .setup_complete exists, exit +if [ -f .setup_complete ]; then + echo "This folder has already been prepped. Please delete the .setup_complete file if you would like to run this script again." + exit +fi + + #if current working directory is named font_files or custom_fonts, exit if [[ $PWD == *"font_files" ]] || [[ $PWD == *"custom_fonts" ]]; then echo "You are in the wrong directory. Please move to the individual font folder." @@ -29,4 +36,5 @@ find . -name '*.ttf' -type f -exec mv {} TTF \; find . -name '*.otf' -type f -exec mv {} OTF \; # Recurse through all folders and subfolders and delete all empty folders -find . -type d -empty -delete \ No newline at end of file +find . -type d -empty -delete +touch .setup_complete \ No newline at end of file