Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
Maybe you can hack up an Automator script that can do it. – Oct 15 '12 at 20:09

Here is another AppleScript like the one posted by user227282:

    tell application "Finder"
        close windows
        if items of trash is {} then return
        open trash
    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

MacOS keeps file meta information about deleted files in ~/.Trash/.DS_Store, which also contains records of the original locations. I've written a perl script that scans ~/.Trash/.DS_Store file and prints commands to move all files back to their original location. The output can be fed directly to shell.

Perl script:

To run, download script, start terminal and type perl

share|improve this answer
Wow, this was the only option that worked for me! Thanks – Andre Soares Jan 12 at 10:50

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

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
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
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. – 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

'Put Back' multiple items in Trash

share|improve this answer
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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .