【分享】Mac批量恢复废纸篓文件脚本

By | 2017/01/18

使用脚本编辑器执行以下脚本即可,虽然方法有些笨拙(就是在循环执行废纸篓里的文件右键“放回原处”),但是很实用,适合批量文件的误删除恢复。

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

发表评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据