What does mdls say about the the offending file?
...
File suffixes, Creator and Type codes and hexdumps:
1. File suffix. Later OSX/macOS versions no longer recognize the old four letter "Type and Creator" codes but rely on the dumber file suffixes like .doc.
mdls [file]
Old Word .doc:
kMDItemContentType = "com.microsoft.word.doc"
New Word .docx:
kMDItemContentType = "org.openxmlformats.wordprocessingml.document"
However, if the suffix happens be wrong (.doc instead of .docx etc), then it is reported wrong there.
If the file has no suffix, macOS uses an Unix EXEC icon that means, "I have no idea what this file is."
2. File Type and Creator. Earlier Mac Systems 0-9 used Type and Creator codes that later OSX/macOS versions no longer recognize:
mdls test.doc
kMDItemFSCreatorCode = "MSWD"
kMDItemFSTypeCode = "W6BN"
Some applications might still insert them but LibreOffice 7 leaves them blank for .doc and .docx:
mdls LibreOffice7.doc
kMDItemFSCreatorCode = ""
kMDItemFSTypeCode = ""
3. If the file suffix happens to be wrong or it does not have it, you can use xxd to check the the first four bytes hex dump of a file:
A Word .doc file:
xxd -l 4 -p doc.doc
d0cf11e0
A Word .docx file:
xxd -l 4 -p docx.docx
504b0304
For example, an old MacWrite 4.5 file with has Creator/Type MACA/WORD:
mdls file
kMDItemFSCreatorCode = "MACA"
kMDItemFSTypeCode = "WORD"
Or:
xxd -l 4 -p file
0006003a
Some 3rd party GUI utilities like FileBuddy could be used to modify Creator/Type info.
Credits to VikingOSX for this info:
https://discussions.apple.com/thread/253009587
See also:
https://en.wikipedia.org/wiki/Creator_code