【问题标题】:Open iCloud in current Finder window with AppleScript使用 AppleScript 在当前 Finder 窗口中打开 iCloud
【发布时间】:2023-03-16 09:02:02
【问题描述】:

我正在尝试在当前的 Finder 窗口/选项卡中打开 iCloud。下面的 AppleScript 适用于任何其他文件夹。

如何使用 AppleScript 在当前 Finder 窗口中打开 iCloud?

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

【问题讨论】:

    标签: applescript icloud


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

      该脚本不起作用,因为 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 文件夹,我刚刚使您的脚本正常工作
      • 这将设置移动文档的路径,但您需要双击或键入“cmd + o”才能打开它。如果这是最好的选择,那么我可能需要解决它(谢谢)但理想情况下,当执行 AppleScript 时,Finder 会立即向您显示 iCloud 文件夹的实际内容,例如“桌面”“文档”等
      • 要实现这一点,您必须将目标设置为文件夹iCloud Drive。我更新了答案。
      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多