使用脚本编辑器执行以下脚本即可,虽然方法有些笨拙(就是在循环执行废纸篓里的文件右键“放回原处”),但是很实用,适合批量文件的误删除恢复。
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 "废纸篓"
end tell
tell process "Finder"
key code 51 using command down
delay 2 -- Yes, it's stupid, but necessary :(
end tell
end tell
end recoverMyFile