Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can put back the items one by one, but there are too many files, how could I restore all the files in the trash?

share|improve this question
1  
Similar: Is there a way to auto “put back” everything in Trash? — Doesn't seem to be possible easily. –  slhck Oct 15 '12 at 15:22
1  
Maybe you can hack up an Automator script that can do it. –  billc.cn Oct 15 '12 at 20:09
add comment

4 Answers

Here is another AppleScript like the one posted by user227282:

repeat
    tell application "Finder"
        close windows
        if items of trash is {} then return
        open trash
        activate
    end tell
    tell application "System Events"
        key code 125 -- down arrow
        key code 51 using command down -- command-delete
    end tell
end repeat

You can run the script by pasting it to AppleScript Editor and pressing command-R. I didn't need any delays.

If Finder shows a password dialog when it tries to put back some item, try adding something like this to the end of the tell application "System Events" block:

delay 1
if exists window 1 of process "SecurityAgent" then
    tell window 1 of process "SecurityAgent"
        set value of text field 2 of scroll area 1 of group 1 to "pa55word"
        click button 2 of group 2
    end tell
end if
delay 1
share|improve this answer
add comment

If it is the last thing you did in the Finder, then using "Undo" would be the preferred method.

There is no built-in way within the GUI to perform the action you are discussing.

This is all assuming that you have not emptied the Trash.

share|improve this answer
add comment

Select all the files you want to put back - Apple Key+A for Select All, then right-click over an item and select Put Back. This will put back multiple items at a time.

share|improve this answer
2  
When you selected all, the Put Back menu will disappear. –  xdazz Oct 15 '12 at 15:41
    
I'm on OS X 10.7.5 and it shows for me. Try it - select all the files in the trash and right click, "Put Back" is there. –  A C Oct 15 '12 at 16:08
3  
It will work if (and only if) all the files are from the exact same folder. Try deleting files from different sources – it won't work. i.stack.imgur.com/q56wI.png –  slhck Oct 15 '12 at 16:10
    
True - you are right. I should have tried more variations. Thanks. –  A C Oct 15 '12 at 16:13
add comment

'Put Back' multiple items in Trash https://gist.github.com/faresd/5661253

share|improve this answer
2  
This looks a little hacky. Could you explain what the script does, for a little more context? That'd be much appreciated. –  slhck May 28 '13 at 8:33
2  
From what I can see, the script tries to close Finder until it is closed, then it reopens it to the trash and puts back the first item in there. After that, it closes all the windows, and repeats. This script uses System Events, which is a very high level of doing something with an AppleScript (it'd be better to do something without taking over the computer interface). If I were the answerer, I would look for a lower-level solution to contribute. –  Carter Pape May 28 '13 at 13:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.