How to find all the Mac files created by a given application

Background: I recently embarked on a project to convert all my old FrameMaker files into formats that I can read on a modern Mac. (The Mac version of FM was discontinued long ago.) I got things set up so that I could run the trial version of FM under Windows under Parallels on a Mac; I would open each FM file, and save it as RTF and PDF.

But before I could do that conversion, I had to find all those old FM files, which were scattered in various folders all through my home directory.

My first attempt to find them was to search for all files with names ending in .fm. I created a list of those files and started opening them, but then I noticed that there were a fair number of files in the same directories that had no filename extension but that were nonetheless FrameMaker files.

Also, there were a fair number of files with no filename extension that turned out not to be FrameMaker files. So the only way I could tell which were which was to try to just open everything in FrameMaker, and ignore the ones that FM couldn’t open.

(In the Finder under modern macOS versions, both the FM files and the relevant non-FM files appear with a “Kind” listed as “Document.” Not helpful, Finder!)

(I have vague memories of being really pleased to learn that I didn’t need to use filename extensions, so I saved a lot of documents without them. If I had known at the time how much of a hassle that would later turn out to be, I would have kept using them.)

It eventually occurred to me that there must be a better way. In particular: in older Mac operating systems, each file had an associated “type” and “creator” (both represented as four-letter strings, often in all-uppercase). And old Mac files still have that metadata even in modern versions of macOS. But I wasn’t sure how to find it.

So I did some searching, and found very useful info in a TidBITS Talk page from 2022.

(That page also includes useful info about how to find Mac filetype and creator on a Windows system, but that wasn’t something I needed to do.)

In particular, the relevant command-line commands were:

View file type for a file: GetFileInfo -t

View creator for a file: GetFileInfo -c

(And if you want more info about a file, you can use GetFileInfo without a flag.)

And it wasn’t too hard to find out the filetype and creator for FM files. Turns out that for ordinary FM documents, the type is FASL, and the creator varies by FrameMaker version number; for example, Fm70 indicates that the file was created by FrameMaker 7.

But I was having trouble writing a command line that would generate a list of files for which GetFileInfo -t returned FASL. (Seems like it should be straightforward, but I ran into some kind of trouble, I don’t remember what.)

So I did some further searching, and found a Stack Exchange page that reveals that on a Mac command line, you can do file -bI (that second flag is a capital letter i) to view the MIME type of a file. And the MIME type of a FrameMaker file is x-mif.

(MIF is Maker Interchange Format, a secondary format that FrameMaker can generate; but x-mif is also used for standard FrameMaker binary files, not only for MIF files.)

So I ended up with the following shell script, an almost exact copy of something from that Stack Exchange page.

#!/bin/sh
# Finds all FrameMaker files in the given directory and its subdirectories, whether or not the filename ends in .fm.
# Very slightly adapted from https://unix.stackexchange.com/questions/483871/how-to-find-files-by-file-type
# (Written by a user who is currently named “Kusalananda on strike”)
find . -type f -exec sh -c '
  for pathname do
    case $( file -bI "$pathname" ) in
      */x-mif*) ;;
      *) continue
    esac
    echo "$pathname"
  done' sh {} +

And that worked! It did exactly what I wanted.

Very pleasing.

Join the Conversation