Created
May 3, 2017 16:00
-
-
Save joncardasis/63b2558739ab1384d93139616cbd0f1f to your computer and use it in GitHub Desktop.
Set the Finder icon of a single file in macOS
This file contains hidden or 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 | |
# Sets an icon for a file | |
# Parameters: | |
# $1 icon_source - file path to the icon soruce (a .icns file) | |
# $2 file_path - file path the the destination file to change the icon of | |
icon_source=$1 | |
file_path=$2 | |
generated_icon=".icon.rsrc" | |
# Create rsrc file | |
DeRez -only icns $icon_source > $generated_icon | |
# Apply rsrc file | |
SetFile -a C "$file_path" | |
Rez -append $generated_icon -o "$file_path" | |
# Removed generated file | |
rm $generated_icon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment