如何重新打开 macOS "recently closed" 或 "open recent" 菜单中列出的所有文件?

How to reopen all files listed in macOS "recently closed" or "open recent" menu?

很少但偶尔,例如在内核崩溃之后,macOS 应用程序不会自动重新打开之前打开的 files/windows。然而,在这些情况下,“最近”或“打开最近”菜单项几乎总是列出这些文件或 windows...但是打开所有这些文件可能很麻烦,单击一个,然后关闭菜单, 重新打开菜单,点击下一步等

有什么方法可以更有效地打开该列表中的所有文件吗?

我尝试搜索以查看是否有任何方法可以同时 select 多个菜单项,并尝试搜索 AppleScript 解决方案,但都没有成功。

以下 AppleScript 解决方案适用于 Finder、Preview 和 TextEdit。 (根据需要更改脚本的第二行。)

它可能也适用于其他应用程序。

--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/10/30 19:17
# dMod: 2021/10/30 19:17 
# Appl: Preview, System Events
# Task: Open All Recent Items Listed in the Recent Items Menu.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Preview, @System_Events, @Open, @Recent, @Items
# Test: Tested only on macOS 10.14.6.
--------------------------------------------------------
# User note: This AppleScript works in macOS 12.0.1.
# I have had success using it with Preview, Finder, and TextEdit.
--------------------------------------------------------

tell application "System Events"
    tell application process "Preview"
        tell menu bar 1
            tell menu "File"
                tell menu item "Open Recent"
                    tell menu 1
                        set recentMenuItems to UI elements whose title is not "Clear Menu" and title is not ""
                        
                        repeat with menuItem in recentMenuItems
                            tell menuItem
                                perform action "AXPress"
                            end tell
                        end repeat
                        
                    end tell
                end tell
            end tell
        end tell
    end tell
end tell

--------------------------------------------------------