macOS CLI for managing custom icons for files and folders
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
fileiconis a macOS CLI for managing custom icons for files and folders, as a programmatic alternative to interactively using Finder.
fileiconallows assigning a custom icon to any file or folder, using any image file whose format is recognized by the system.
Caveat: Custom icons rely on extended attributes of the macOS filesystems, HFS+ and APFS. Therefore, custom icons are lost when copying files or folders to filesystems that don't support these attributes; for instance, custom icons cannot be stored in a Git repository.
When assigning an image file with
fileicon set, a set of icons in several resolutions is created and stored in the resource fork of the target file itself / of a hidden
Icon\rfile inside the target folder.
The icon with the highest resolution measures 512 x 512 pixels, and the input
image is scaled accordingly.
Note that input images that aren't square can result in distorted icons; for best results, provide square images.
# Assign custom icon derived from image file 'img.png' to file 'foo': fileicon set foo img.png
Remove previously assigned custom icon from folder 'foodir':
fileicon rm foodir
Extract custom icon from file 'foo' to icon file 'foo.icns':
fileicon get foo
Test if folder 'foodir' has custom icon:
fileicon test foodir
With Homebrew installed, run the following:
brew install fileicon
Tip of the hat to @danielbayley for creating and submitting the formula.
[sudo] npm install fileicon -g
sudodepends on how you installed Node.js and whether you've changed permissions later; if you get an
EACCESerror, try again with
-gensures global installation and is needed to put
fileiconin your system's
chmod +x fileicon.
$PATH, such as
Find concise usage information below; for complete documentation, read the manual online, or, once installed, run
fileicon --manif installed manually).
$ fileicon --help Manage custom icons for files and folders on macOS. SET a custom icon for a file or folder: fileicon set  REMOVE a custom icon from a file or folder: fileicon rm GET a file or folder's custom icon: fileicon get [-f]  -f ... force replacement of existing output file TEST if a file or folder has a custom icon: fileicon test All forms: option -q silences status output. Standard options: --help, --man, --version, --home
This project gratefully depends on the following open-source components, according to the terms of their respective licenses.
npm dependencies below have optional suffixes denoting the type of dependency; the absence of a suffix denotes a required run-time dependency:
(D)denotes a development-time-only dependency,
(O)an optional dependency, and
(P)a peer dependency.
Versioning complies with semantic versioning (semver).
README.mdupdated with Homebrew installation instructions.
filecon setis now short for
filecon set; that is, you can now more conveniently make an image file use itself as its icon.
) in lieu of an actual image file, which is not supported.
sips -ifor icon creation to a Python-based Cocoa call to
NSWorkSpace.setIcon(_:forFile:options:), courtesy of https://apple.stackexchange.com/a/161984/28668 As a result, icons in multiple resolutions are now generated, with a top resolution of 512 x 512 pixels (previously: 128 x 128)
fileicon --manon a system where the man page isn't installed.