使用 AppleScript 在当前 Finder window 中打开 iCloud

Open iCloud in current Finder window with AppleScript

我正在尝试在当前的 Finder window/tab 中打开 iCloud。以下 AppleScript 适用于任何其他文件夹。

如何使用 AppleScript 在当前的 Finder window 中打开 iCloud?

tell application "Finder"
    reopen
    activate
    set p to "~/Library/Mobile Documents/"
    set target of Finder window 1 to POSIX file p
end tell

该脚本不起作用,因为 Finder 无法扩展 POSIX 路径中的波浪号。

这是一个相对路径的替代方案。

set userLibraryFolder to path to library folder from user domain
tell application "Finder"
    reopen
    activate
    set iCloudDriveFolder to folder "iCloud Drive" of folder "Mobile Documents" of userLibraryFolder
    set target of Finder window 1 to iCloudDriveFolder
end tell

这不是一个完整的答案,因为这不会在当前选项卡中打开 iCloud 文件夹,但它 打开iCloud 文件夹而不是 "Mobile Documents" 文件夹:

tell application "System Events" to open folder "~/Library/Mobile Documents"

我不熟悉任何能让您两全其美的方法。看来您要么必须满足于在您想要的选项卡中打开的 "Mobile Documents" 文件夹;要么或正在创建一个新选项卡以打开您想要的文件夹。

这很简单。 创建 iCloud 文件夹的别名并将其放在本地硬盘驱动器上,然后使用 Apple 脚本打开别名并打开 iCloud 文件夹: 将 itemPath 设置为“Macintosh HD:Users:username:folder:alias_name” 告诉应用程序“Finder” 将 theItem 设置为项目 itemPath 如果 (class of theItem) 是文件夹然后激活 打开项目 结束告诉