Last active
January 12, 2025 04:55
-
-
Save remino/9fee925c29cd5c254d389fb669f6c1fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* | |
!.gitignore | |
!make-macos-folder-icns.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# make-macos-folder-icns.sh | |
# by Rémino Rem <https://remino.net>, 2024-06-24 | |
# Convert .png file sets into macOS .icns icon files. | |
# | |
# Export 'macOS Folder Icons (Community).zip' from Figma: | |
# | |
# - Go to: <https://www.figma.com/design/fMbYLvi41EGhxnO5IYDdRx/macOS-Folder-Icons-(Community)> | |
# - Select all the "macos-folder-*" layers on the left. | |
# - Click "Export 10 layers" on the right. | |
# | |
# This should give you a 'macOS Folder Icons (Community).zip' file. | |
# | |
# Save file in the same directory as 'make-macos-folder-icns.sh' and run it. | |
set -e | |
if [ "$(uname)" != "Darwin" ]; then | |
echo "Error: This script is for macOS only." | |
exit 16 | |
fi | |
( | |
reqs_missing=0 | |
if ! command -v iconutil > /dev/null; then | |
echo "Error: 'iconutil' not found. Install Xcode command line tools." | |
reqs_missing=1 | |
fi | |
if ! command -v rename > /dev/null; then | |
echo "Error: 'rename' not found. Install 'rename' (e.g. via Homebrew)." | |
reqs_missing=1 | |
fi | |
if [ $reqs_missing -ne 0 ]; then | |
exit 17 | |
fi | |
) | |
cd "$(dirname "$0")" || exit 18 | |
if [ ! -f "macOS Folder Icons (Community).zip" ]; then | |
echo "Error: 'macOS Folder Icons (Community).zip' not found." | |
echo "See $0 for instructions." | |
exit 16 | |
fi | |
if [ -d "macOS Folder Icons (Community)" ]; then | |
rm -fr "macOS Folder Icons (Community)"/* | |
else | |
mkdir "macOS Folder Icons (Community)" | |
fi | |
cd "macOS Folder Icons (Community)" | |
unzip ../"macOS Folder Icons (Community).zip" | |
# Deleting the original icons as they are not the correct sizes for the .icns file | |
# and likely not needed anyway. | |
rm -fr "macos-folder-original"* | |
ls * | sed -E 's/[0-9].*//' | grep -E '^mac[a-z-]+$' | sort | uniq | while read dir; do | |
rename "s/^$dir/icon_/" "$dir"* | |
mkdir -p "$dir.iconset" | |
rm -fr icon_*-*.png | |
mv -v "icon_"*.* "$dir.iconset" | |
echo "$dir.icns" | |
iconutil -c icns -o "$dir.icns" "$dir.iconset" | |
done | |
rm -fr *".iconset" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you add a
rm -fr "$dir.iconset"
at the end, its a nice way to clean up the folder only leaving behind the.icns
files.Also
rename
is not available through MacOS. I had to install it via brew. Most people will miss this.