在 OS X 的 Finder 功能中显示文件

rog*_*ack 5 mac finder macos

我熟悉

explorer /select,/path/to/something
Run Code Online (Sandbox Code Playgroud)

在 Windows 资源管理器中打开包含文件的文件夹,突出显示该文件。任何人都知道使用 Finder 对 OS X 执行相同操作的单行(或单行 Applescript)?谷歌搜索似乎没有透露太多的一种班轮的方式。

Kev*_*vin 11

open命令通常就像您双击一个文件一样,但它有一个-R标志来显示 finder 中的参数。因此,您正在寻找:

open -R /path/to/something
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅打开的手册页。


Lri*_*Lri 5

Finder 的 AppleScript 字典有一个reveal命令:

tell app "Finder" to reveal POSIX file "/private/etc"
Run Code Online (Sandbox Code Playgroud)

但它不会将 Finder 带到前面或使用您创建的窗口的默认视图选项。

这还应该同时执行以下两项操作:

tell application "Finder"
    reopen
    activate
    set selection to {}
    set target of window 1 to (POSIX file "/private/etc")
end tell
Run Code Online (Sandbox Code Playgroud)