"Put Back" from Trash app?

I have a friend that deleted thousands of files erroneously and is now going through one by one and putting them back.

Is it possible to have applescript to select them all and put them all back automatically?

I looked everywhere on this forum and could not find this solution.

Thanks.

Here’s what I’m using. I keep it in the Script Menu. It needs the Trash open and the files selected to work.

NOTE: if you aren’t using a US keyboard then the “key code” for the delete key (51) may be different. The script really just types ⌘+Delete keys


tell application "Finder"
	activate
	if not (exists window "Trash") then
		open trash
		display alert "Error" message "Select files to restore then re-run this script" giving up after 10
		error number -128
	end if
end tell

tell application "System Events" to tell process "Finder" to tell window "Trash"
	key code 51 using {command down}
end tell