App icon from command line

ericbenfer
Contributor II

I am looking for a command line way to extract the icon from an app. Any ideas? Apps in Big Sur do not necessarily have an icns file in the app bundle. (I’m looking at you System Preferences)

1 REPLY 1

Mauricio
Contributor III

If you are looking for a "one-off" copy of icons a quick way would be:
Create a folder /tmp/myIcons
Then try to get all icons

find /  -name "*.icns" -exec cp '{}' "/tmp/myIcons" ;

A few prompts to "Allow" later and you should have some 1000 files.
Looking for System and I found 'SystemPrefApp.icns'

A second find and we can get the path to that file.

find / -name "SystemPrefApp.icns"
/System/Library/CoreServices/ManagedClient.app/Contents/PlugIns/ConfigurationProfilesUI.bundle/Contents/Resources/SystemPrefApp.icns

No a nice way but could be a starting point.