FileAssociationsFinder is a Swift command-line utility that helps users find macOS applications capable of opening files with a specific file extension. The utility utilizes the NSWorkspace
and UniformTypeIdentifiers
frameworks to perform the search.
- Quickly find apps that can handle a given file extension.
- Outputs full application paths for easy reference.
- Gracefully handles cases where no apps are found.
- macOS 11.0 (Big Sur) or later.
- Swift 5.3 or later.
- Clone the repository or copy the
FileAssociationsFinder.swift
file. - Ensure you have Xcode or Swift command-line tools installed.
- Build the project using the Swift compiler or Xcode.
- Open a terminal and navigate to the directory containing
FileAssociationsFinder.swift
. - Compile the program:
swiftc -o FileAssociationsFinder FileAssociationsFinder.swift
- Run the program with a file extension as an argument:
Replace
./FileAssociationsFinder <file-extension>
<file-extension>
with the desired file extension (e.g.,txt
,png
,pdf
).
./FileAssociationsFinder txt
/Applications/TextEdit.app
/Applications/Visual Studio Code.app
If no applications are found:
No apps found for extension txt
Usage: ./FileAssociationsFinder <file-extension>
- The program accepts a file extension as a command-line argument.
- It converts the extension into a Uniform Type Identifier (UTI) using
UTType
. - It queries macOS's
NSWorkspace
to find compatible apps. - Application paths are extracted from the returned URLs and displayed.
- macOS-only utility, as it relies on macOS-specific frameworks.
This utility is released under the MIT License. Modify and use it freely!