I accidentally moved over 4,000 files to the trash, and I want to move the files back to their original locations. While the Lion supports this feature (via the Finder's "Put Back" command), it will only allow you to Put Back one file at a time.
I found an AppleScript script to automate the process of Putting Back files one file at a time. I ran the script overnight and it mostly worked, but 1,700 files remained in my trash.
The problem is the remaining files require me to enter a password before the Put Back can take place. I believe these files were created under a different owner.
My question is how can I get around this?
Is there a way to enter a superuser mode that eliminates me having to enter a password for every file I want to undelete?
Any help is greatly appreciated.
Here is the AppleScript:
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