forked from erikng/adminscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractAppIconToDesktopAsPng.sh
More file actions
executable file
·31 lines (31 loc) · 1.13 KB
/
extractAppIconToDesktopAsPng.sh
File metadata and controls
executable file
·31 lines (31 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Jacob Salmela
# Find out the name of the icon of the .app passed to this script as an argument
if [[ -z "$1" ]];then
echo "Please provide a path to an .app";exit 1
else
if [[ $1 != *.app ]];then
:
else
# Check the Info.plist for the icon's name
iconFile=$(defaults read "$1"/Contents/Info.plist CFBundleIconFile 2>/dev/null)
appName=$(basename "$1")
pngFilename="${appName%.*}"
# If there is no icon, there is nothing to do
if [[ -z "$iconFile" ]];then
:
else
# Get the file extension as some values don't have it in the .plist but the actual file does
extension="${iconFile##*.}"
# So if there is no file extension, set one so it can be appended to the filename so it can be used in the sips command
if [[ "$extension" != "icns" ]];then
fileExtension="icns"
echo "* Converting $iconFile.$fileExtension to a PNG..."
sips -s format png "$1"/Contents/Resources/"$iconFile.$fileExtension" --out ~/Desktop/"$iconFile".png
else
echo "* Converting $iconFile.$fileExtension to a PNG..."
sips -s format png "$1"/Contents/Resources/"$iconFile" --out ~/Desktop/"$pngFilename".png
fi
fi
fi
fi