【问题标题】:Applescript to select the last file in folder (listed by name ascending)Applescript 选择文件夹中的最后一个文件(按名称升序列出)
【发布时间】:2021-08-26 15:42:31
【问题描述】:

寻找 AppleScript 以添加到自动机工作流程中,该工作流程将选择按名称升序列出的文件夹中的最后一个文件,然后继续使用 Automator 工作流程。

【问题讨论】:

    标签: file select applescript automator


    【解决方案1】:

    这是脚本的答案,在脚本编辑器中执行,如果 Automator 此刻对你来说很困难。

    set theFolder to choose folder
    
    tell application "Finder"
        select last item of (sort files of theFolder by name)
        activate
        delay 10 -- to see visually
    end tell
    

    【讨论】:

      【解决方案2】:

      如果我正确理解您的问题,那么以下应该作为 Automator 操作:

      on run {input, parameters}
          set theFolder to item 1 of input
          tell application "Finder"
              select last item of (sort files of theFolder by name)
          end tell
      end run
      

      【讨论】:

      • 我将以上内容复制/粘贴到我的工作流程中,但它不起作用。错误:“操作“运行 AppleScript”遇到错误:“操作无法完成。 (com.apple.Automator 错误 -212。)“
      • 我将原始 Automator 工作流接收的内容更改为“文档”,然后更改为“自动(文件或文件夹)”,两次都返回此错误:“操作“运行 AppleScript”遇到错误: "无法获取 {} 的最后一项。"
      • 不确定我是否应该将此工作流/脚本设置为在选定文件夹或文件夹中的选定文件上运行。
      • 选择的文件夹,不要忘记在运行工作流之前手动选择文件夹
      • “获取选定的 Finder 项目” 操作应该在您的工作流程中排在第一位,而我的 “运行 AppleScript” 操作应该排在第二位。或者您没有工作流程,而是快速行动?这是不同的事情。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多