make a certain file type hidden

I am trying to find a way to make my mac see .dSYM files as hidden. I know I could do:

chflags hidden / -name *.dSYM

but the next time I create a .dSYM file it wont be hidden. There must be a way to tell finder to hide a certain file type (all currently on my machine, plus all that I will create in the future).

I am assuming that just because it is hidden, it wont affect my ability to use the .dSYM files when I am running cgdb in terminal? Or do the have to be not hidden for cgdb to be able to find them?

(I am on Mountain Lion)


Solution 1:

AFAIK there isn't a direct way to do this. There are several alternatives though:

  • Folder Actions: Create a folder action (which gets triggered upon each change in a folder) to run the chflags command if needed. As Folder Actions only apply to to one folder this needs an Action for every folder you create .dSYM files in
  • launchd: Use WatchPaths to run a script whenever one of the listed paths is modified
  • Hazel: Hazel is kind of like Folder Actions on steroids and allows you to create actions based on various rules

PS: cgdb isn't affected, chflags only makes files invisible on Finder level (and in Open/Save dialogs).