{"id":20119,"date":"2023-08-01T12:49:09","date_gmt":"2023-08-01T19:49:09","guid":{"rendered":"https:\/\/www.kith.org\/jed\/?p=20119"},"modified":"2024-08-01T08:44:10","modified_gmt":"2024-08-01T15:44:10","slug":"how-to-find-all-the-mac-files-created-by-a-given-application","status":"publish","type":"post","link":"https:\/\/www.kith.org\/jed\/2023\/08\/01\/how-to-find-all-the-mac-files-created-by-a-given-application\/","title":{"rendered":"How to find all the Mac files created by a given application"},"content":{"rendered":"\r\n<p>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.<\/p>\r\n<p>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.<\/p>\r\n<p>My first attempt to find them was to search for all files with names ending in <code>.fm<\/code>. 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.<\/p>\r\n<p>Also, there were a fair number of files with no filename extension that turned out <em>not<\/em> 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\u2019t open.<\/p>\r\n<p>(In the Finder under modern macOS versions, both the FM files and the relevant non-FM files appear with a \u201cKind\u201d listed as \u201cDocument.\u201d Not helpful, Finder!)<\/p>\r\n<p>(I have vague memories of being really pleased to learn that I didn\u2019t 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.)<\/p>\r\n<p>It eventually occurred to me that there must be a better way. In particular: in older Mac operating systems, each file had an associated \u201ctype\u201d and \u201ccreator\u201d (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\u2019t sure how to find it.<\/p>\r\n<p>So I did some searching, and found very useful info in a <a href=\"https:\/\/talk.tidbits.com\/t\/finding-type-creator-tags-in-old-mac-document-files\/18041\/5\">TidBITS Talk page<\/a> from 2022.<\/p>\r\n<p>(That page also includes useful info about how to find Mac filetype and creator on a Windows system, but that wasn\u2019t something I needed to do.)<\/p>\r\n<p>In particular, the relevant command-line commands are:<\/p>\r\n<p>View file type for a file: <code>GetFileInfo -t<\/code><\/p>\r\n<p>View creator for a file: <code>GetFileInfo -c<\/code><\/p>\r\n<p>(And if you want more info about a file, you can use <code>GetFileInfo<\/code> without a flag.)<\/p>\r\n<p>And it wasn\u2019t too hard to find out the filetype and creator for FM files. Turns out that for ordinary FM documents, the type is <code>FASL<\/code>, and the creator varies by FrameMaker version number; for example, <code>Fm70<\/code> indicates that the file was created by FrameMaker 7.<\/p>\r\n<p>But I was having trouble writing a command line that would generate a list of files for which <code>GetFileInfo -t<\/code> returned <code>FASL<\/code>. (Seems like it should be straightforward, but I ran into some kind of trouble, I don\u2019t remember what.)<\/p>\r\n<p>So I did some further searching, and found a <a href=\"https:\/\/unix.stackexchange.com\/questions\/483871\/how-to-find-files-by-file-type\">Stack Exchange page<\/a> that reveals that on a Mac command line, you can do <code>file -bI<\/code> (that second flag is a capital letter <i>i<\/i>) to view the MIME type of a file. And the MIME type of a FrameMaker file is <code>x-mif<\/code>.<\/p>\r\n<p>(MIF is Maker Interchange Format, a secondary format that FrameMaker can generate; but <code>x-mif<\/code> is also used for standard FrameMaker binary files, not only for MIF files.)<\/p>\r\n<p>So I ended up with the following shell script, an almost exact copy of something from that Stack Exchange page.<\/p>\r\n<pre>\r\n#!\/bin\/sh\r\n# Finds all FrameMaker files in the given directory and its\r\n# subdirectories, whether or not the filename ends in .fm.\r\n# Very slightly adapted from\r\n# https:\/\/unix.stackexchange.com\/questions\/483871\/how-to-find-files-by-file-type\r\n# (Written by a user who is currently named \u201cKusalananda on\r\n# strike\u201d)\r\nfind . -type f -exec sh -c '\r\n  for pathname do\r\n    case $( file -bI \"$pathname\" ) in\r\n      *\/x-mif*) ;;\r\n      *) continue\r\n    esac\r\n    echo \"$pathname\"\r\n  done' sh {} +\r\n<\/pre>\r\n<p>And that worked! It did exactly what I wanted.<\/p>\r\n<p>Very pleasing.<\/p>\r\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[79,133],"tags":[],"class_list":["post-20119","post","type-post","status-publish","format-standard","hentry","category-computers","category-writing-samples"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/posts\/20119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/comments?post=20119"}],"version-history":[{"count":7,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/posts\/20119\/revisions"}],"predecessor-version":[{"id":21122,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/posts\/20119\/revisions\/21122"}],"wp:attachment":[{"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/media?parent=20119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/categories?post=20119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kith.org\/jed\/wp-json\/wp\/v2\/tags?post=20119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}