Since macOS High Sierra sips --addIcon is no longer supported.
An easier way to add and image to a file/folder is to use fileicon npm package.
The new syntax is:
fileicon set foo img.pngThe old method setIcon is kept here a an archive:
Take an image and make the image its own icon:
sips -i icon.pngExtract the icon to its own resource file:
DeRez -only icns icon.png > tmpicns.rsrcAppend this resource to the file you want to icon-ize.
Rez -append tmpicns.rsrc -o file.extUse the resource to set the icon.
SetFile -a C file.extAppend a resource to the folder you want to icon-ize.
Rez -append tmpicns.rsrc -o $'myfolder/Icon\r'Use the resource to set the icon.
SetFile -a C myfolder/Hide the Icon\r file from Finder.
SetFile -a V $'myfolder/Icon\r'rm tmpicns.rsrc
Source: Stackexchange
The is some kind of a bug with the change of icons of "folders" nor files, al last in Catalina. When the Icon change it does not refresh in the UI when the folder have a custom older icon set.
By looking to a workaround, found this little fix (no ideal but works): - this is in JXA Javascript for automation