Why do empty "Icon\r" or "Icon^M" files appear in directories?

There's an empty file called Icon^M occasionally in my directories. I guess this stuff predates OSX, and it's a file that gets created by the finder to be backward compatible with OS 9. Yet, this is my guess. I tried to google, but given the name, I had some trouble finding something meaningful (in the sense that it explain what the file is and where it comes from, historically).

If you have any reference at hand I would enjoy learning this bit of lore.


Do you have by any chance a custom icon you set up for that folder?

I believe this is what this file is there for.


This Super User answer has the answer.