Iterate over each folder.

and also update the .setup_complete bits.
This commit is contained in:
Matt Troutman 2024-09-27 11:14:23 -05:00
parent a169586df5
commit 6ef0940881
No known key found for this signature in database
2 changed files with 50 additions and 1 deletions

41
iterate.sh Normal file
View file

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

View file

@ -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
find . -type d -empty -delete
touch .setup_complete