app.finder - Finder Operations API

Interact with macOS Finder.

Note: All Finder operations are executed asynchronously and return true immediately without guaranteeing the operation succeeded.

Methods

app.finder.open(path)

Open a file or directory with the default application.

Parameters:

  • path (string) - File or directory path

Returns: boolean - Always returns true (executed asynchronously)

-- Open a file
app.finder.open("/path/to/document.pdf")

-- Open a directory
app.finder.open("/path/to/folder")

app.finder.openWith(path, appName)

Open a file with a specified application.

Parameters:

  • path (string) - File path
  • appName (string) - Application name

Returns: boolean - Always returns true (executed asynchronously)

app.finder.openWith("/path/to/file.txt", "Visual Studio Code")
app.finder.openWith("/path/to/file.txt", "Sublime Text")

app.finder.select(path)

Select a file in Finder (opens the containing directory and selects the file).

Parameters:

  • path (string) - File path

Returns: boolean - Always returns true (executed asynchronously)

app.finder.select("/path/to/file.txt")

app.finder.reveal(path)

Same as select - reveal a file in Finder.

Parameters:

  • path (string) - File path

Returns: boolean - Always returns true (executed asynchronously)

app.finder.reveal("/path/to/file.txt")

Examples

Reveal File After Processing

function MyPlugin:handleConvert(context)
    for _, file in ipairs(context.selectedFiles) do
        local outputPath = app.path.removeExtension(file) .. ".png"

        if app.image.convert(file, outputPath) then
            -- Conversion successful, reveal in Finder
            app.finder.reveal(outputPath)
        end
    end
end

Open with a Specific Application

function MyPlugin:handleOpenWithEditor(context)
    for _, file in ipairs(context.selectedFiles) do
        app.finder.openWith(file, "Visual Studio Code")
    end
end
Developer Documentation
User Guide
Getting Started Script Menus FAQ
Script Development
Development Guide
Plugin Development
Quick Start Development Guide Example Plugins
API Reference
Overview API Query Plugin Info Logging Finder Context Plugin Settings Internationalization
UI & Interaction
Dialog Progress Notification Chooser WebView Status Bar Dock
Files & Paths
File Operations Path Utilities Finder Actions Trash Extended Attributes Metadata File Watcher
Data Formats
JSON Plist CSV XML PDF Image
Text & Encoding
String Regex Date & Time Color Crypto
System
Shell Commands Process Application System Info AppleScript Shortcuts
System Info
Network Power/Battery Screen/Appearance Audio Bluetooth Location
Network
HTTP WebSocket URL
Input & Clipboard
Keyboard Mouse Hotkey Clipboard Window
Storage
SQLite Keychain UserDefaults
Media
OCR QR Code
Utilities
Archive UTI Share Timer Wake Lock Thread