Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jozeppy26

macrumors 6502a
Original poster
Jul 8, 2008
533
77
St. Louis
Is there anyway to use the native "put back" feature to restore 11,000 items that are currently in the Trash?

Files originated from many different folders throughout the OS. The "Put Back" option in the contextual menu is greyed out unless only 1 file is selected at a time. Has anyone ever tried (and succeeded) at writing something in Automator or an Applescript to batch "put back" each file individually? Or do I really have to use "command + delete" & close the opening folder 11,000 times? My friend is panicking.

I've tried google searching for a repair to this issue, but I only get a bunch of posts from 2010 with people claiming that "Mac's don't put back anything from the trash. Oh wait, I guess I was wrong, it does" but then no one continues to research the issue.
 

w0lf

macrumors 65816
Feb 16, 2013
1,268
109
USA
Maybe try this?

Finally I managed to restore all my files by writing an AppleScript, which was inspired by this source http://www.giacomoballi.com/applescript.html
The original script did not work for me, as it uses keystrokes on the current finder window. On OS X Lion (I guess also on previous versions) the put back reveals the original location in a new finder window, so subsequent delete keystroke in the repeat cycle would delete a file again.... Anyhow, if anybody finds it useful, I copy it here. Be careful, no warranties so only use it if you know what you're doing. One more sidenote, if your trash contains a file which can not be restored anyhow, you need to skip it somehow when it comes to the top. I had such files, but I did not bother with this too much as I sorted the view by last access time and these files became the last ones in the list. Good luck and keep pokeing Apple to make them provide somehow this trivial feature.

Code:
repeat 4173 times --or as many files you have
          tell application "Finder" to open trash --open the trash folder
          tell application "Finder" to activate
          tell application "System Events"
                    tell process "Finder"
  delay 0.2 -- adjust delay as needed
  key code 125 --move down to get focus on a file
  key down command --hold command key
  delay 0.2 -- adjust delay as needed
  key code 51 --hit delete
  key up command --release command
                    end tell
          end tell
  delay 0.2 -- adjust delay as needed
          tell application "Finder" to close every window --close everything for the next cycle
end repeat
 

jozeppy26

macrumors 6502a
Original poster
Jul 8, 2008
533
77
St. Louis
that'll do it. I ran into the same issues with the original code, thank goodness there's someone smart enough to fix it. Many thanks to you and OP.
 

tomtom2

macrumors newbie
Jul 4, 2013
1
0
Put Back All Files from Trash

I accidentally deleted 1,057 files. I really need those back in their original location.

I tried to run the script and it is doing something but it doesn't move the files.

Any idea?

Thank you in advance.
 

canuckuk1

macrumors newbie
Oct 22, 2013
2
0
files moved to trash with mackeeper!!!

Does ANYONE know how i can put back all the files that have been moved into my trash by mackeeper where they belong...i tried selecting them one bye one and using the put back option but its greyed out!! i have all the files in tact but i dont know where to put them or how to do it...if anyone has any ideas i would greatly appreciate it!!! i tried using the apple script above but it wont work:( im using an imac 10.8.5 and i live in the UK if that helps anyone with an answer for me...HELLLLPPPPPPPPPP PLEASE!!! im loosing my mind my apps and programmes are not working properly coz the files are out of place:(
 

nxPLQh2SWAjHLnQ

macrumors newbie
Jan 15, 2014
1
0
"Put Back" files from Trash

For years all that was required to move files from Trash back to their original locations was to select "Put Back" using "Action" gear icon on command bar.What happened to this option and how can it be retrieved? Requiring an "application" to perform a single function formerly handled by use of the "Action" [gear icon] command is absurd: adds unnecessary complexity, wastes available system space, and ultimately detracts from a certain economic measurement known as Gross Domestic Product[ivity].*
 

rikitrader

macrumors newbie
Dec 26, 2015
1
0
Maybe try this?

Hello Mr. Wolf,

You wrote these script which is awesome. Is there a way to make a command that if the script finds a file that it has not put back option, it will continue to the next file?

Let me know if it's possible, the reason is because some of the files were corrupted since when I realized that I was dealing the files I tried to stop them.

Waiting for your Good News.

You original script was :

https://forums.macrumors.com/threads/batch-put-back-files-from-trash-to-original-location.1573914/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.