mdfind query on kMDItemFSTypeCode can't find some type codes I just upgraded to a new MacBook with Lion, and having discovered that some of my old apps can't come with, I'm scouring my files for certain types that will need to be converted to future-proof formats. A lot of these files go back to System 7 and some never had filename extensions (d'oh), so I figured the best way to find them would be to search by the old-style creator/type codes.

I've been using the mdfind command with success for most type codes, but I've discovered that its results aren't always consistent. Here's an example of what's going wrong when I try to find 3DMF files.

First I run mdls to verify the type code:

$ mdls garage.3DMF

kMDItemContentCreationDate     = 2002-06-24 02:05:20 +0000
...
kMDItemFSCreatorCode           = "OP40"
...
kMDItemFSTypeCode              = "3DMF"
kMDItemKind                    = "3dmf"
...


"Ah, so it's '3DMF'," I think. So now I run mdfind on the same directory to verify it's working:

mdfind -onlyin . "kMDItemFSTypeCode == '3DMF'"


But nothing is returned! In fact, nothing comes back when I run it over the entire drive, even though I have 3DMF files scattered all over.

Running a general query (mdfind 3DMF) seems to do the job, but it's overkill and returns a lot of false positives. Is there something obvious I'm doing wrong here?
You have to translate the type code string into an actual type code (a number).

For your '3DMF', that number is 860114246. Thus, this will work:

mdfind kMDItemFSTypeCode == 860114246