Skip to content

Instantly share code, notes, and snippets.

@mralexgray
Created December 4, 2011 13:52
Show Gist options
  • Save mralexgray/1430251 to your computer and use it in GitHub Desktop.
Save mralexgray/1430251 to your computer and use it in GitHub Desktop.
geticon.sh, utility app icons.scpt

geticon.sh

#!/bin/sh

appname=`echo "$*" | sed 's|\.app$||'`
apppath=`mdfind -onlyin /Applications/ -onlyin ~/Applications/ -onlyin /Developer/Applications/ -onlyin /System/Library/CoreServices/ "kMDItemKind=='Application'" | grep -i "/$appname.app\$"`
bundleicon=`defaults read "$apppath/Contents/Info" CFBundleIconFile | sed 's|.icns$||'`
cp "$apppath/Contents/Resources/$bundleicon.icns" ~/Desktop/"$appname".icns

utility app icons.scpt

tell application "Finder"
	repeat with f in (get selection)
		do shell script "apppath=" & quoted form of POSIX path of (f as text) & "; appname=`echo \"$apppath\" | sed 's|.app$||;s|.*/||'`; icns=`defaults read \"$apppath\"/Contents/info CFBundleIconFile | sed 's|.icns$||'`; cp \"$apppath/Contents/Resources/$icns.icns\" \"$HOME/Desktop/$appname.icns\""
	end repeat
end tell

for f in *.icns; do sips -Z 128 -s format jpeg -s formatOptions 60 "$f" -o "${f%.*}.jpg"; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment