Here’s a sample script using a new feature introduced in macOS 26:
it allows you to set a folder color and place a single character inside the folder icon.
I don’t think anyone has shared this yet, so I’m posting it here.
20251017
I apologize.
Please allow me to make a correction.
There was an error in the emoji settings.
It turns out that multiple characters are allowed, not just a single character.
I’m sorry for so many corrections.
20251025 I’ve added the license information.
#!/bin/zsh
#com.cocolog-nifty.quicktimer.icefloe
#set -x
#export PATH=/usr/bin:/bin:/usr/sbin:/sbin
#20251007 fixed Example
#20251013 I changed the way the PLIST file is created.
#20251017 change comment and Example: emoji multiple characters are allowed
#20251025 I’ve added the license information.
#
# License Notice
# CC0 1.0 Universal (Public Domain Dedication).
#########################
#For Emoji
#パスの指定
#Set File and Dir path
STR_TMP_DIR_PATH=$(/usr/bin/mktemp -d)
STR_TMP_JSON_PATH="${STR_TMP_DIR_PATH}/tag.json"
STR_TMP_PLIST_PATH="${STR_TMP_DIR_PATH}/label.plist"
#ユーザーのデスクトップにフォルダを作る
#make new folder on user desk top
STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
STR_DIR_PATH="/Users/${STAT_USR}/Desktop/ColorFolder"
#フォルダを作ります
# Create a folder
/bin/mkdir -p "${STR_DIR_PATH}"
#JSONを作ります
# Create a JSON file with the emoji you want to render
STR_JSON_DICT_VALUE="(>_<)"
/usr/bin/jq -n --arg emoji "${STR_JSON_DICT_VALUE}" '{"emoji": $emoji }' > "${STR_TMP_JSON_PATH}"
#訂正 一文字だけ→複数文字可能
#文字でも複数文字入れると文字が小さくなります
#たぶん SF Proに収録されている文字なら設定可能
# Correction: previously assumed only a single character → multiple characters are allowed
# If multiple characters are entered, the text may appear smaller
# Probably works with characters included in the SF Pro font
# STR_JSON_DICT_VALUE="🃛🃛"
# STR_JSON_DICT_VALUE="⌘v"
# STR_JSON_DICT_VALUE="☠️☠️☠️"
# STR_JSON_DICT_VALUE="💰📈"
# STR_JSON_DICT_VALUE="🇺🇸LAX"
# STR_JSON_DICT_VALUE="‼"
# STR_JSON_DICT_VALUE=""
#JSONをバイナリーで読み込み xattrで値をセットします
# Read the JSON in binary and set the value using xattr
/usr/bin/xattr -x -w com.apple.icon.folder\#S "$(/usr/bin/xxd -p "${STR_TMP_JSON_PATH}" | tr -d '\n')" "${STR_DIR_PATH}"
#更新します
# Update
/usr/bin/SetFile -a C "${STR_DIR_PATH}"
#PLISTを作ります
# Create a PLIST
# The sample [ブルー] uses a Japanese label name; in English, it will probably appear in [Blue]
#EN
/bin/echo '["Red"]' | /usr/bin/plutil -convert xml1 -o "${STR_TMP_PLIST_PATH}" -
#JA
#/bin/echo '["ブルー"]' | /usr/bin/plutil -convert xml1 -o "${STR_TMP_PLIST_PATH}" -
#PLISTをバイナリーで読み込み xattrで値をセットします
# Read the PLIST in binary and set the value using xattr
/usr/bin/xattr -x -w com.apple.metadata:_kMDItemUserTags "$(/usr/bin/xxd -p "${STR_TMP_PLIST_PATH}" | tr -d '\n')" "${STR_DIR_PATH}"
#更新します
# Update
/usr/bin/SetFile -a C "${STR_DIR_PATH}"
#########################
#For SF Symbols
#パスの指定
#Set File and Dir path
STR_TMP_DIR_PATH=$(/usr/bin/mktemp -d)
STR_TMP_JSON_PATH="${STR_TMP_DIR_PATH}/tag.json"
STR_TMP_PLIST_PATH="${STR_TMP_DIR_PATH}/label.plist"
#ユーザーのデスクトップにフォルダを作る
#make new folder on user desk top
STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
STR_DIR_PATH="/Users/${STAT_USR}/Desktop/ColorFolderSF"
#フォルダを作ります
# Create a folder
/bin/mkdir -p "${STR_DIR_PATH}"
#JSONを作ります
# Create a JSON file with the SF Symbols Name you want to render
STR_JSON_DICT_VALUE="applescript.fill"
/usr/bin/jq -n --arg sym "${STR_JSON_DICT_VALUE}" '{"sym": $sym }' > "${STR_TMP_JSON_PATH}"
#例
#Example
# STR_JSON_DICT_VALUE="house.fill"
# STR_JSON_DICT_VALUE="trash.slash"
# STR_JSON_DICT_VALUE="textformat.characters.arrow.left.and.right"
# STR_JSON_DICT_VALUE="externaldrive.connected.to.line.below.fill"
#JSONをバイナリーで読み込み xattrで値をセットします
# Read the JSON in binary and set the value using xattr
/usr/bin/xattr -x -w com.apple.icon.folder#S "$(/usr/bin/xxd -p "${STR_TMP_JSON_PATH}" | tr -d '\n')" "${STR_DIR_PATH}"
#更新します
# Update
/usr/bin/SetFile -a C "${STR_DIR_PATH}"
#PLISTを作ります
# Create a PLIST
# The sample [ブルー] uses a Japanese label name; in English, it will probably appear in [blue]
#EN
/bin/echo '["Red"]' | /usr/bin/plutil -convert xml1 -o "${STR_TMP_PLIST_PATH}" -
#JA
#/bin/echo '["ブルー"]' | /usr/bin/plutil -convert xml1 -o "${STR_TMP_PLIST_PATH}" -
#PLISTをバイナリーで読み込み xattrで値をセットします
# Read the PLIST in binary and set the value using xattr
/usr/bin/xattr -x -w com.apple.metadata:_kMDItemUserTags "$(/usr/bin/xxd -p "${STR_TMP_PLIST_PATH}" | tr -d '\n')" "${STR_DIR_PATH}"
#更新します
# Update
/usr/bin/SetFile -a C "${STR_DIR_PATH}"
exit 0
Hope you find it helpful!
The symbol names for SF Symbols can be found in the SF Symbols app
20251007 fixed Example
20251013 I changed the way the PLIST file is created.


