Keeping A Backup of Icons in MacOS

You have probably created nice icons for your volumes or folders, only have them get removed at some point that you cannot remember. To keep from losing it, you can easily keep a backup of it. You can keep it in icns format, or make a PNG out of it.

From a command line (Terminal or SSH), you cd to the folder in question that has a custom icon that you like; this can also be the top level of a volume.

For a Volume’s icon, cd into the volume’s mount “/Volumes/<Volumename>“. If you run the command “ls -la“, it will show you a list of all files, including the “invisible” files that begin with a period (.). You will see a file called “.VolumeIcon.icns“. This is the icon file. To make a backup of this file, run a command in the form:

cp -X .VolumeIcon.icns /path/to/backup/MyIcon.icns 

The -X tells it to strip the extended attributes from the file, which includes a setting to tell the Finder that the file is invisible. It is an attribute that is set in addition to the file name beginning with a period (.).

If you want a PNG version of the icon, you can run the command:

sips -s format png .VolumeIcon.icns --out MyIcon.png

Side Note: In the Finder, if you want to see invisible files, you can hold Command and Shift, then hit the period (.). This is a toggle.

To get the icon from a Folder, the process is a bit different. The folder icons still store it using resource forks from the pre-OSX days, so it is trickier. The easiest way is to simply Get Info in the Finder on the folder, and click the small icon by the name of the file at the top. Then run Preview, close the “Open File” dialog, and then Command-N to create a new file, which will auto-fill with all the versions of the image from the icns file. You can then save the highest resolution version of that file as a PNG. Once you have that PNG, you can then make it into an icon icns file.

Leave a Comment