A command-line utility that prints the Uniform Type Identifier for the files provided as an argument.
- macOS 10.4+
$ uti Hello.swift
public.swift-source
Results for multiple path arguments are printed on separate lines in the order they're provided:
$ uti index.html screen.css app.js
public.html
public.css
com.netscape.javascript-source
If any of the provided file path arguments are invalid,
the command exits with status code 1
and prints a message to standard error.
$ uti invalid
error: invalid is not a file or directory
You can combine uti
with other Unix commands.
For example,
to list the UTI for each file in a directory,
you might invoke the find
command like so:
$ ls .
Xcode_11.xip
Xcode.app
$ find . -exec uti {} +
com.apple.xip-archive
com.apple.application-bundle
Run the following command to install using homebrew:
$ brew install nshipster/formulae/uti
Run the following commands to build and install manually:
$ git clone https://github.com/NSHipster/uti.git
$ cd uti
$ make install
uti
delegates to the mdls
system command,
requesting the kMDItemContentType
metadata attribute
and processing the output.
MIT
Mattt (@mattt)