If you customize a Finder icon, macOS will put an Icon file in that directory.
While ls -al
will show the filename as Icon?
, the real file name is Icon$'\r'
, which can be found using Zsh's autocomplete functionality. Yes, the last character is a carriage return. Why, you may ask. That's a fair question.
Anyhow, to apply the hidden flag to all icon files located recursively within the current directory, run this command:
find . -name Icon$'\r' -exec chflags hidden {} +