Sample Header Ad - 728x90

Associate another filename extension with existing UTI

1 vote
0 answers
92 views
The macOS system recognizes various files as JavaScript. If the filename extension is .js, .jscript, .javascript or .mjs, the file's Uniform Type Identifier (UTI) is com.netscape.javascript-source and the file is considered to be JavaScript. This list of filename extensions is 'hard-coded' in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist, where that UTI is defined in a dictionary entry with this subkey:
UTTypeTagSpecification

	public.filename-extension
	
		js
		jscript
		javascript
		mjs
	
	public.mime-type
	
		text/javascript
I would like to add another filename extension to the set that identifies JavaScript files on my Mac. The extension .jsm is often used with the same meaning as .mjs, a JavaScript module. For example, the source code of Firefox has 484 jsm files and the source code of Thunderbird has 429. If they could have that same UTI, it would become easier to work with them – for example, they'd be treated the same by Quicklook. Is this possible? Can you override the built-in UTI definition, or somehow add something to it? Editing this system file seems unwise (and will have to be repeated after every OS update). I tried doing it in the Info.plist of an ad-hoc Automator application, and then importing that app with lsregister, but have so far had no luck. My question is similar to [this one](https://apple.stackexchange.com/questions/24373/how-can-i-associate-a-file-extension-with-a-content-type) , but more specific.
Asked by Jim Danner (146 rep)
Apr 14, 2023, 01:01 PM