File Applescript选择文件夹中的最后一个文件(按名称升序列出)

File Applescript选择文件夹中的最后一个文件(按名称升序列出),file,select,applescript,automator,File,Select,Applescript,Automator,正在寻找要添加到automator工作流的AppleScript,该工作流将选择按名称升序列出的文件夹中的最后一个文件,然后继续automator工作流。如果我正确理解您的问题,则以下操作应作为automator操作: on run {input, parameters} set theFolder to item 1 of input tell application "Finder" select last item of (sort fi

正在寻找要添加到automator工作流的AppleScript,该工作流将选择按名称升序列出的文件夹中的最后一个文件,然后继续automator工作流。

如果我正确理解您的问题,则以下操作应作为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

下面是脚本的答案,在脚本编辑器中执行,如果此时自动机对您来说很困难

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

我将上述内容复制/粘贴到我的工作流程中,但它不起作用。错误:“运行AppleScript”操作遇到错误:“操作无法完成。(com.apple.Automator error-212。)“我将原始Automator工作流接收的内容更改为“文档”,然后更改为“自动(文件或文件夹)”,它两次都返回此错误:“运行AppleScript”操作遇到错误:“无法获取{}的最后一项。”不确定是否应将此工作流/脚本设置为在选定文件夹或文件夹中的选定文件上运行。选定文件夹,并且在运行工作流之前,不要忘记手动选择文件夹“获取选定查找项”操作应在工作流中排在第一位,而我的“运行AppleScript”操作应排在第二位。或者您没有工作流,但是快速操作?这是不同的事情。