Jump to content

Hoping for help in learning how to built a little AppleScript


magdan
 Share

2 posts in this topic

Recommended Posts

Hi,

 

Il wil really appreciate any help for this! Thansk to whomever had the patience to read my question!

 

I wish that someone could help me in writing an Apple Script to limit access to a specific folder, by that, I mean, to change the Ownership & Permissions of that folder (in it's get Info) to : no Access

 

this would only be a dissuasive means of opening this folder.

 

As far as now (I'm an absolute beginner in AppleScript), I've wrote a script to promt a dialog asking for a password…

What I wish to do is :

 

1. Attach the AppleScript to the specific folder (so, when an intruder doubleclicks on it, the Apple Scripts starts)

2. Ask for a password for that specific folder with a (repeat twice)

3. If the answer is right, than, modifiy the Ownership & Permission to : Read and Write (and make the folder visible if it was hidden)

4. Else (if these are already in : Read and Write) change the Ownership & Permission to : No Access (for everyone : Owner, Group, Others)

5. And, (in the Else) if the answer is wrong, hide the folder.

6. And finally, (if the answer is right) restore everything to normal (reset pribileges and visibility)…

 

Here is the result of what I could understand from Apple Script :

 

set prompt to "Password?"

repeat 3 times

set dialogResult to display dialog prompt ¬

buttons {"Annuler", "OK"} default button 2 ¬

default answer "Wrong" with icon 1 with hidden answer

set thePassword to text returned of dialogResult

if thePassword is "pass" then

exit repeat

else

if thePassword is not "pass" then

display dialog "Wrong"

end if

end if

end repeat

if thePassword = "pass" then

display dialog "OK"

 

end if

 

So, to resume :

1. How does one attache a script to a specific folder (or item)?

2. How can an Apple Script access the "Ownership & Permission" (in the Get Info, of that specific folder or item) and changes its values?

3. How can an Apple Script restore (or reset) these values to their original state?

 

I'm French and I spent two days reading (searching really!) the English Apple Script Language Guide… trying to create a dissuasive Script to prevent my kid's friends to acces some of my folders with whatever I could gather. But this doesn't look like a friendly and intuitive Guide to me…!

 

Thanks for any help!

 

Dan

post-325818-1227574634_thumb.jpg

Link to comment
Share on other sites

  • 4 months later...
 Share

×
×
  • Create New...