homebrew-fonts/prep 1 font.sh
Matt Troutman eb865b1dc3
Merge branch 'font-prep'
* font-prep:
  Fonts prepped 🎉
  Don't track the .setup_complete files.
  Fix double quotes
  Cleanup
  setup scripts
  account for TTC files.
  Iterate over each folder.
  using the script to move things around.

# Conflicts:
#	prep 1 font.sh
2024-09-27 12:42:01 -05:00

48 lines
No EOL
1.8 KiB
Bash
Executable file

#! /bin/zsh
#uncomment if you want to delete all .setup_complete files and process everything
#find . -name '*.setup_complete' -type f -delete
#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."
exit
fi
#recursively find all .zip files and unzip them
find . -name '*.zip' -exec unzip {} \;
# Make OTF and TTF folders if they don't exist
mkdir -p OTF TTF "other files"
# Recurse through all folders and subfolders and move files that are not .ttf or .otf into the "other files" folder
find . -type f -exec mv {} "other files" \;
# Recurse through all folders and subfolders and delete all .DS_Store files
find . -name '.DS_Store' -type f -delete
# Recurse through all folders and subfolders and delete all .g2n files
find . -name '*.g2n' -type f -delete
find . -name '*.ofm' -type f -delete
find . -name '*.cfg' -type f -delete
find . -name '*.zip' -type f -delete
# Recurse through all folders and subfolders and move all .ttf files into the TTF folder
find . -name '*.ttf' -type f -exec mv {} TTF \;
# Recurse through all folders and subfolders and move all .ttc files into the TTF folder
find . -name '*.ttc' -type f -exec mv {} TTF \;
# Recurse through all folders and subfolders and move all .otf files into the OTF folder
find . -name '*.otf' -type f -exec mv {} OTF \;
# Recurse through all folders and subfolders and delete all empty folders
find . -type d -empty -delete
# create a .setup_complete file to indicate that the folder has been prepped
touch .setup_complete