Hello,
I need an applescript that when I run it it will change the “ownership & permissions” of a folder named “works folder” to “No Access”.
This is the file path for that folder: “LaCie 200 works:projects:in process:works folder:”
Would someone here mind lending me a hand? I think I can modify it as another script to change it back to “Read & Write”. -Sincere thanks to anyone who even looks at this post. -Rob
p.s.
I’ve searched this forum and have found many different pieces of code that is similar to what I’m trying to do. Unfortunately, I’m such a novice at all of this I don’t really know how to modify the stuff I’ve found to the degree that it will work for my purposes.
Below, is the closest thing that I’ve found to accomplishing this. However, it is a folder action and I need an applescript application:
-- change this to the path to your destination folder
property DestinationFolder : alias "Macintosh HD:Users:username:Desktop:destination:"
on adding folder items to this_folder after receiving added_items
repeat with thisfile in added_items
tell application "Finder"
set owner privileges of thisfile to read write
set group privileges of thisfile to read write
set everyones privileges of thisfile to read write
move thisfile to folder DestinationFolder
end tell
end repeat
end adding folder items to
Try something like this:
-- change this to your folder
property targetFolder : alias "LaCie 200 works:projects:in process:works folder:"
display dialog "Change permissions to." buttons {"Cancel", "No Access", "Read & Write"} default button 3
set _permissions to button returned of result
tell application "Finder"
if _permissions is "No Access" then
set owner privileges of targetFolder to none
set group privileges of targetFolder to none
set everyones privileges of targetFolder to none
else
set owner privileges of targetFolder to read write
set group privileges of targetFolder to read write
set everyones privileges of targetFolder to read write
end if
end tell
Bruce, once again man… You rock!
One thing though…
It’s kinda weird. Perhaps you might understand why it’s doing this…
If I manually, get info and open the folder and change the permissions to “no access” then apps that access the files in this folder report back a “can’t locate file” error [BTW this is my desired result].
However, when I run the scrip and set the folder’s permissions to “no access” my apps that access the files in this folder, unfortunately, open them with no problem. I know the permissions have changed to “no access” becacue that’s what it says when I perform a “get info” on the folder. Also, I’m denied access to opening the folder until I change the permissions back to “read & write”. However, for some reason the rest of the OS seems to be uninformed that access has been denied. Is there someway to refresh the OS so that it takes this change seriously? I’ve tried restarting the apps that look to the folders contentents but they still have access. Any ideas?
Thanks again. -Rob