今天不小心刪了2000多個文件。打開廢紙簍想還原文件,ctrl+A全選,點擊右鍵發現沒有“
放回原處”選項。悲催了,難道要一個一個恢復嗎?如果用Timemachine來恢復,那新文檔又要被沖掉了。在網上研究了半天,現將方法整理如下:
- 同一個目錄下的文件,可以一起恢復
- 不同目錄下的文件,不可以一起恢復,右鍵沒有“放回原處”
- 運用AppleScript批量恢復誤刪的文件
>打開Automator
>選擇“服務”
>左側找到“AppleScript”,雙擊進入
>填入以下代碼
tell application "Finder"
activate
set file_count to count of (trash's items)
-- log file_count
repeat file_count times
recoverMyFile() of me
end repeat
end tell
on recoverMyFile()
tell application "System Events"
set frontmost of process "Finder" to true
tell application "Finder"
open trash
select the first item of window "廢紙簍"
--中文版macos"廢紙簍",英文版macos"Trash"
end tell
tell process "Finder"
key code 51 using command down
delay 1 -- Yes, it's stupid, but necessary :(
end tell
end tell
end recoverMyFile
>點擊黑色三角型運行,開始恢復。
注意:恢復的速度很慢,如果你能判斷哪些文件是在同一個目錄下,可以手工先恢復一些。
閱讀更多 貓眼評說 的文章