1 篇文章带有标签 “Finder”

macOS Finder 中的“反向选择”功能实现(Automator)

通过 Automator 制作一个“快速操作”的方案。请按照以下的步骤操作:

  1. 打开 Automator,新建一个 “快速操作”
  2. 设置:“工作流程收到当前”选 “没有输入”,“位于”选 “Finder.app”
  3. 在搜索框输入 AppleScript,拖入 “运行 AppleScript” 动作。
  4. 清空原内容,粘贴以下这段代码:
on run {input, parameters}
    tell application "Finder"
        -- 获取当前窗口,如果没有窗口则退出
        if (count of windows) = 0 then return
        set win to front window
        
        -- 获取文件夹内所有对象的路径列表
        set all_items to every item of win
        set all_paths to {}
        repeat with i in all_items
            set end of all_paths to (POSIX path of (i as alias))
        end repeat
        
        -- 获取当前已选对象的路径列表
        set sel_items to selection
// ...

保存并命名为 “反向选择”。