本文目录导读:

Windows系统
PowerShell脚本
# 清除最近使用的文件列表 Clear-RecycleBin -Force # 清除Windows资源管理器最近文档 Remove-Item "$env:APPDATA\Microsoft\Windows\Recent\*" -Recurse -Force -ErrorAction SilentlyContinue # 清除Office最近文档 Get-ChildItem "$env:APPDATA\Microsoft\Office\Recent\*" -ErrorAction SilentlyContinue | Remove-Item -Force # 清除跳转列表 Remove-Item "$env:APPDATA\Microsoft\Windows\Recent\AutomaticDestinations\*" -Force -ErrorAction SilentlyContinue Remove-Item "$env:APPDATA\Microsoft\Windows\Recent\CustomDestinations\*" -Force -ErrorAction SilentlyContinue # 清除注册表中的MRU列表 reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs" /f reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU" /f reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU" /f Write-Host "最近文档记录已清除!"
批处理脚本(.bat)
@echo off echo 正在清除最近文档记录... :: 删除最近文档文件夹内容 del /f /s /q "%APPDATA%\Microsoft\Windows\Recent\*.*" 2>nul :: 清除注册表项 reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs" /f reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU" /f reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU" /f reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" /f :: 清理跳转列表 del /f /s /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\*" 2>nul del /f /s /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations\*" 2>nul :: 重启资源管理器(可选) taskkill /f /im explorer.exe start explorer.exe echo 已完成!按任意键退出... pause >nul
macOS系统
AppleScript脚本
tell application "System Events"
-- 清除最近项目
tell application "Finder"
-- 清空最近文件夹
set recentFolder to path to recent items folder from user domain
delete every item of folder recentFolder
end tell
-- 清除应用程序最近文档
tell application "System Events"
set recentApps to every process whose background only is false
repeat with appProc in recentApps
try
set appPath to path of appProc
do shell script "defaults delete " & quoted form of appPath & " NSRecentDocumentRecords 2>/dev/null"
end try
end repeat
end tell
end tell
display dialog "最近文档记录已清除!" buttons {"确定"} default button 1
Shell脚本
#!/bin/bash # 清除Finder最近文档 rm -f ~/Library/Preferences/com.apple.recentitems.plist rm -rf ~/Library/Recent\ Items/* # 清除Spotlight最近搜索 defaults delete com.apple.spotlight recentItems 2>/dev/null # 清除应用程序的最近文档 find ~/Library/Preferences -name "*RecentDocument*" -delete 2>/dev/null find ~/Library/Application\ Support -name "*Recent*" -delete 2>/dev/null # 重启Dock和Finder killall Dock killall Finder echo "最近文档记录已清除!"
Linux系统
Bash脚本
#!/bin/bash # 清除GNOME最近文件记录 rm -f ~/.local/share/recently-used.xbel rm -f ~/.recently-used # 清除KDE最近文档 rm -f ~/.kde/share/apps/RecentDocuments/* rm -f ~/.local/share/RecentDocuments/* # 清除GTK最近文件列表 rm -f ~/.gtk-bookmarks # 清除应用特定最近记录 find ~/.config -name "*recent*" -delete 2>/dev/null find ~/.local -name "*recent*" -delete 2>/dev/null # 清除命令行历史 history -c rm -f ~/.bash_history rm -f ~/.zsh_history echo "最近文档记录已清除!"
使用方法
- Windows批处理脚本:保存为
.bat文件,右键选择"以管理员身份运行" - PowerShell脚本:保存为
.ps1文件,右键选择"使用PowerShell运行",或先执行Set-ExecutionPolicy RemoteSigned - macOS/Linux脚本:保存后执行
chmod +x script.sh赋予执行权限,./script.sh运行
注意事项
⚠️ 请谨慎操作:
- 这些操作不可逆,执行后无法恢复已清除的记录
- 建议先备份重要数据
- 某些应用可能需要重启才能生效
- 在企业环境中,可能需要IT管理员权限
如果需要更精确的控制或特定应用的清理,请告诉我你使用的操作系统和想要清理的具体应用,我可以提供更针对性的脚本。