Skip to content

Instantly share code, notes, and snippets.

@james-see
Created March 10, 2025 00:24
Show Gist options
  • Save james-see/74b008a37c7eddf2202376c2a5099afb to your computer and use it in GitHub Desktop.
Save james-see/74b008a37c7eddf2202376c2a5099afb to your computer and use it in GitHub Desktop.
install fonts from subfolders in icloud
#!/bin/bash
# iCloud fonts folder path
ICLOUD_FONTS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/free-fonts"
# Destination macOS Fonts folder
DESTINATION="$HOME/Library/Fonts"
# Temporary folder for extracted zip files
TEMP_UNZIP="$HOME/.tmp_fonts"
# Ensure destination and temp unzip folder exist
mkdir -p "$DESTINATION"
mkdir -p "$TEMP_UNZIP"
# Function to find and install fonts
install_fonts() {
echo "Searching for fonts in: $ICLOUD_FONTS"
# Find and extract all zip files
find "$ICLOUD_FONTS" -type f -iname "*.zip" | while read -r zipfile; do
echo "Extracting: $zipfile"
unzip -o "$zipfile" -d "$TEMP_UNZIP"
done
# Move extracted fonts from TEMP_UNZIP to ICLOUD_FONTS (so they get picked up)
find "$TEMP_UNZIP" -type f -iname "*.ttf" -o -iname "*.otf" -o -iname "*.ttc" -exec mv {} "$ICLOUD_FONTS" \;
# Find all font files and copy them to macOS Fonts folder
find "$ICLOUD_FONTS" -type f \( -iname "*.ttf" -o -iname "*.otf" -o -iname "*.ttc" \) | while read -r font; do
echo "Installing: $(basename "$font")"
cp -n "$font" "$DESTINATION"
done
# Cleanup
rm -rf "$TEMP_UNZIP"
echo "All fonts installed. You may need to restart apps to see them."
}
install_fonts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment