Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file.icns that I would like to set as custom icon for a folder. How can I do it from a script/command-line? The script is executed in the postinstall phase of a package installer. The language of the script can be any of the script languages supported by the package-maker (bash,perl,applescript should be fine).

share|improve this question

I found this (I did not test, but appears to be what you want):

share|improve this answer
The linked solution uses utils from the Developer Tools. But, since the script must be executed by an installer package, this cannot possibly work, unless those tools are distributed inside the package, which of course I'm not allowed to do. – Valerio Schiavoni Jun 29 '10 at 18:02
@Valerio Perhaps I'm missing something obvious, but folder icons are supplied by an invisible file called Icon within the folder. Why can't your installer package install this file along with everything else? – ghoppe Jun 29 '10 at 18:55
how would I do that? – Valerio Schiavoni Jun 29 '10 at 21:37
I eventually found a little Obj-C script that does perfectly the job: – Valerio Schiavoni Jun 30 '10 at 7:51
The assignIcon script doesn't work for me. I get an error: #<stdin>:1: ### /Developer/Tools/Rez - SysError 0 during read. – e40 May 16 '12 at 18:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .