2

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?

1 Answer 1

1

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
2
  • 1
    I do not know how to get the integer, but kMDItemFSTypeCode also accepts the type code as an hex value. Convert it to hex on the fly with: mdfind -onlyin . "kMDItemFSTypeCode == 0x$(echo -n '3DMF'|xxd -p)"
    – elmimmo
    Jun 6, 2020 at 17:26
  • @elmimmo You are looking for e.g. stackoverflow.com/a/14222771/341994
    – matt
    Jun 6, 2020 at 17:55

You must log in to answer this question.

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