【问题标题】:How to open finder on Mac OS X automatically when USB plugged in?USB插入时如何在Mac OS X上自动打开finder?
【发布时间】:2015-04-04 14:07:32
【问题描述】:

超级简单的问题,但我不喜欢答案。

我希望 Finder 在插入 USB 驱动器时打开已安装的磁盘...如何?

【问题讨论】:

    标签: macos usb usb-drive


    【解决方案1】:

    谢谢@mark-setchell

    我已经为我的 /Volumes 文件夹找到了这个 Apple 脚本:

    on adding folder items to this_folder after receiving added_items
        try
            tell application "Finder"
                --open window and activate finder 
                activate
                --open the USB
                open added_items
            end tell
        end try
    end adding folder items to
    

    因此,每当 /Volumes 文件夹中出现一些新项目时,Finder 都会打开窗口并选择该项目。

    此解决方案在打开取景器之前会有一些延迟(5-10 秒)。我猜文件夹操作就是这样工作的......

    【讨论】:

      【解决方案2】:

      您应该能够通过将Folder Action 添加到文件夹Volumes 来执行此操作,这是安装外部磁盘的位置。 AFAIK,您只能在 Finder 中执行此操作,并且 /Volumes 文件夹在 Finder 中设置为不可见 - 感谢 Apple。

      所以,首先通过启动终端并运行,使 /Volumes 文件夹对 Finder 可见

      sudo SetFile -a v /Volumes
      

      现在,启动 Finder 并选择您的系统驱动器,然后在左侧窗格中选择 Macintosh HD。您现在应该看到

      • 应用程序
      • 图书馆
      • 系统
      • 用户

      右键单击Volumes 文件夹并转到Setup Folder Actions 并附加add - new item 脚本。然后,您可以随意使用它来执行您希望 Finder 在插入磁盘时执行的任何操作。

      【讨论】:

        【解决方案3】:

        添加到@MarkSetchell 的答案中,为了使 /Volumes 文件夹可见,我必须改用 sudo chflags nohidden /Volumes。然而,使该文件夹可见(并且可能是首选的临时)的更简单方法是使用组合键:

        Cmd (⌘) + Shift + .

        (我的上下文菜单项也是Services > Folder Actions Setup

        为了避免其他人的痛苦,保存这些脚本的文件夹是/Library/Scripts/Folder Action Scripts(我很惭愧地说我花了几个小时才找到它)

        使用终端和 sudo 在此处创建一个新文件,粘贴上面的脚本,并将其添加到文件夹操作设置中。它就像一个魅力(至少对我来说)。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-10-19
          • 1970-01-01
          • 1970-01-01
          • 2012-03-12
          • 2010-09-30
          • 2015-01-19
          • 2010-11-20
          • 1970-01-01
          相关资源
          最近更新 更多