Created
October 23, 2014 06:52
-
-
Save lepture/7874bac8bb5746cbaa2d to your computer and use it in GitHub Desktop.
replace icon for mac application and folder
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/bash | |
| BIN=/Applications/Xcode.app/Contents/Developer/Tools/ | |
| DeRez=$BIN/DeRez | |
| Rez=$BIN/Rez | |
| iconify() { | |
| ICON="$1"; FOLDER="$2" | |
| if [[ -f $ICON && -d $FOLDER ]]; then | |
| TMP_DIR=$(mktemp -d -t iconify) | |
| cp "$ICON" "$TMP_DIR/icon.icns" | |
| sips -i "$TMP_DIR/icon.icns" | |
| $DeRez -only icns "$TMP_DIR/icon.icns" > "$TMP_DIR/icon.rsrc" | |
| $Rez -append "$TMP_DIR/icon.rsrc" -o "$FOLDER"/$'Icon\r' | |
| SetFile -a C "$FOLDER" | |
| SetFile -a V "$FOLDER"/$'Icon\r' | |
| else | |
| echo "File or folder not found" | |
| fi | |
| } | |
| if [[ "$1" && "$2" ]]; then | |
| iconify "$1" "$2" | |
| else | |
| echo "Usage: iconify example.icns /path/to/folder" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment