I am working on a Mac (Yosemite, OS X 10.10.5) and I have several mht files which I created on Firefox by selecting File → Save as MHT. I have already associated the files with Firefox — it opens them by default — but the files continue to show the exec icon. What I am looking for is a way to make macOS recognize the mht file extension: for eg, when a PDF file is renamed in macOS, only the name of the file is highlighted but not the extension, however when a mht file is renamed, both the name of the file and the file extension (mht) are hightlighed.

I tried browsing to Firefox -> Show Package Contents -> Contents and, since it was missing, I added mht to the Info.plist using TextEdit:

        <string>mht</string> <!-- added -->
    <string>HTML Document</string>

This did not work. Is there any way to make macOS recognize the mht extension and associate it to the Firefox icon? Alternatively, how can I make macOS associate an icon to these files (other than manually changing the icon on each file in the Get Info window)?

  • Where are your .mht files? Are they on an external drive? – SilverWolf Dec 24 '17 at 15:42
  • Yes @seaturtle most of them are on an external drive. The ones that are on my computer don't have an exec icon but a blank page icon. The extension is not recognized at such in either case. – Leia Dec 25 '17 at 18:23

In the comments, you indicated that the problem files were on an external drive. Is it formatted as FAT (or NTFS)?

These filesystems have no concept of executable files, so the system seems to assume that everything is an executable program. Don't worry, there's nothing wrong with the file.

Why does it do this? Well, it's a permissions problem.

To see the permissions on a file, you can open a terminal, type ls -ld with a space after it, drag in your file, and press Return. The first part of the output will look like this:


So what does all this mean?

r: read  w: write  x: execute

    -        rwx     rwx     rwx
    |       └─┬─┘   └─┬─┘   └─┬─┘
additional  user    group   world
  info     perm.s   perm.s  perm.s

Try this on some file in your home folder. You should get something like rw-r--r--. Now try something on your external drive—it's probably rwxrwxrwx.

(External drives usually don't have a concept of ownership, so even on an HFS+-formatted drive you'll get the same set in each field. Edit: I tested this on a random file and it came back with rw-r--r--. Oops.)

Fixing the problem

The proper way

If the partition the file is on is formatted HFS+ (like your system disk) or any Unix filesystem (e.g. ext4, XFS), then you can use chmod. To do this, type chmod -x into a terminal, add a space, and drag in your file, just as with ls above. Hit Return, and you should be golden.

In fact, this is always worth a shot—it's safe to try on any type of filesystem. If it doesn't work, see below.

The improper way—just hiding it

On filesystems with no concept of executable files, chmod will silently fail and nothing will happen. You can still hide this by setting an icon. To do this, Get Info on a file (⌘I) and drag a .icns file onto the icon in the top left corner. (You can also just copy and paste the icon from something else—that's probably the way to go here. If you want a custom icon, read on.)

So, how do you get this mysterious .icns file?

The easiest way is simply to open an image in Preview, select everything (⌘A), and copy it (⌘C). Then you can just paste it into the corner icon (click to select it first).

But .icns images have a hidden benefit—they can display differently at different sizes. This is great for app icons, which is their main reason for existence. If you want to make your own image do this, you can do the following:

Slightly off-topic: making your own icon images behave differently at different sizes

  1. Collect a set of images, with sizes of 64x64 up to 1024x1024. These are for Retina displays, you'll downsize them later. Put them in a folder named whatever.iconset.
  2. Rename each of them to icon_<halfwidth>x<halfheight>@2x.png (for example, the 64px icon would be icon_32x32@2x.png).
  3. Duplicate each icon, halve its size, and rename it icon_<newwidth>x<newheight>.png (for example, icon_32x32.png). This can be automated with a shell script, using the sips command (run man sips for more info on using it).

You'll see that if you Quick Look preview the folder, you'll see your icon, and see how it behaves at different sizes.

  1. Convert it to a .icns with this command: iconutil --convert icns and drag in your iconset, as with the other commands.

Associating the file type with Firefox

I don't know whether your process would have worked, but you'll need to make sure the system can see the change. You do this with lsregister:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister .../Firefox.app

Replace .../Firefox.app with the path to Firefox, or drag it into the terminal.

  • Thank you for your detailed explanation, I really appreciate it. My external drive is formatted as NTFS, but I tried what you suggested and you are right: when running the command on a file in the external drive the output is -rwxrwxrwx and when I ran it on a file in my home folder the output is -rw-r--r--. Sorry if this question is a bit silly, but I don't understand why the exec icon is associated to the -rwxrwxrwx permission configuration and a blank page icon is associated to the -rw-r--r-- configuration... – Leia Dec 29 '17 at 20:57
  • It's not silly at all! As far as I know, it just assumes it's an executable file (and uses that icon) if your current permissions (user if you own the file, group if you don't but are in the same group, etc.) include x. – SilverWolf Jan 2 '18 at 21:55
  • You can see this by setting the x permission using the chmod command: type chmod +x, add a space, and drag in some document (like with the ls command above). After running the command, its icon should change. Repeat this command with -x instead to undo it. – SilverWolf Jan 2 '18 at 21:56
  • Also, you can set an icon by dragging a .icns file into the Get Info window. This will override the executable icon. (Of course, if you run into this on an HFS+ partition, the right way to fix this is with chmod -x. :) – SilverWolf Jan 2 '18 at 22:02
  • @searturtle Thank you so much for your answer, I really appreciate your taking the time to help me. Since my files are on an NTFS drive, all I can do is go the improper way and just hide them ;) I added an icon to one of the mht files using the Get Info window. I then tried to associate the file type with Firefox using the code you suggested: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister/Applications/Firefox.app but I get the following error message: Not a directory. What am I doing wrong? I am sorry to keep bothering you with this! – Leia Jan 9 '18 at 1:15

You must log in to answer this question.

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