我想清除计算机上的最近项目列表,无论它们来自哪个软件。到目前为止,我知道以下列表:
如何清除这些菜单中的项目?
据我所知,没有内置的方法可以做到这一点,因为最近的文档存储在每个应用程序的首选项文件中。然而,一点 AppleScript 和:
tell application "Finder"
set fls to every file in alias ":Users:ben:Library:Preferences:"
set AppleScript's text item delimiters to {""}
repeat with fl in fls
if name extension of fl is "plist" then
set fn to name of fl
set pid to text items 1 thru -7 of fn as text
if pid = "com.apple.Xcode" then
try
do shell script "defaults delete " & pid & " NSRecentXCFileDocuments"
do shell script "defaults delete " & pid & " NSRecentXCProjectDocuments"
end try
else
try
do shell script "defaults delete " & pid & " NSRecentDocumentRecords"
end try
end if
end if
end repeat
end tell
Run Code Online (Sandbox Code Playgroud)
这涉及普通应用程序和 Xcode,但不涉及 Apple 菜单或其他不遵循该模式的应用程序。