Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

So a funny thing happened to me last night. I was trying to clean files off my Macbook Pro.

I just purchased a new Macbook Retina and it has a smaller hard drive than my old Macbook Pro (I know cry me a river).

Anyway I was in Finder and I found a whole bunch of files and I selected them all and hit the good old delete key.

And gosh darn if my Mac didn’t immediately got to working whacking my files.
What I didn’t realize that I had a view of my entire network of files including my Dropbox documents, family pictures and even some naughty images from my college years (don’t tell my wonderful wife).

The total number of deleted files was over 4,000. I almost cried.

No big deal I just go to the Trash and undelete right? Not so fast Tonto!

I want to have the files moved back to their original location. While the Lion supports this feature, it will only allow you do restore one file at a time.

With 4,000+ files my eyeballs would fall out by the time I finished.

Fortunately someone at Apple invented Apple Script.

And someone else wrote a script that will undelete files one file at a time.

I ran the script went to bed and found that it worked!!!!

Of the 4,000 file only 1,700 remained in my trash (Woo Hoo!!!).

The problem is the remaining files require me to enter a password before the restore 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 super duper user mode that eliminates me having to enter a password for every file I want to undelete?

Any help is greatly appreciated.

share|improve this question
    
Do you have write access to the folders these files used to be in? –  Nathan Greenstein Jul 19 '12 at 16:22
    
Nathan I believe I would have to enter a password to update these files. –  codingguy3000 Jul 19 '12 at 16:49
1  
Restore from Time Machine. –  Thorbjørn Ravn Andersen Jul 20 '12 at 7:23
    
cross-posted at Super User and Stack Overflow –  Lri Jul 20 '12 at 17:42

2 Answers 2

Applescript has a parameter administrator privileges which adding it to your script will execute the command as Administrator.

Extracted from Apple's Apple Script Language Guide:

Execute the command as the administrator? Once a script is correctly authenticated, it will not ask for authentication again for five minutes. The elevated privileges and the grace period do not extend to any other scripts or to the rest of the system. For security reasons, you may not tell another application to do shell script with administrator privileges. Put the command outside of any tell block, or put it inside a tell me block. Default Value: false

So it should be something like do shell script "whatEver" with administrator privileges.

share|improve this answer

Alternatively, run the script using sudo, e.g. in the prompt, type:

sudo command

where command is whatever you want to run as root (super-user). You'll be prompted once for your password, but then the command will run with escalated privileges.

share|improve this answer

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.