I need to get the current group name of user owned items items and if “admin”, change to “staff”.
I thought that this will do it. It does not.
tell application "Finder"
set mySelection to selection as alias list
set theItem to item 1 of mySelection
set item_group to group of theItem
if item_group is "admin" then set group of theItem to "staff"
end tell
It fails because the command
set item_group to group of theItem
returns “(unknown)” instead of “admin” (or “staff” for that matter) for any item whose owner is not “system”,
Note that, when the item’s owner is “system”, the command returns an acceptable “root”, while “Get info” shows “wheel”.
Checking the item’s properties reveals these results:
tell application "Finder"
set mySelection to selection as alias list
set theItem to item 1 of mySelection
set item_properties to properties of theItem
--For user owned items, the group is always "(unknown)" instead of "staff" or "admin",
--> {class:document file, name:"Ï€ test.scpt", index:1, displayed name:"Ï€ test.scpt", name extension:"scpt", extension hidden:false, container:folder "Desktop" of folder "chris" of folder "Users" of startup disk of application "Finder", disk:startup disk of application "Finder", ... owner:"chris", group:"(unknown)", owner privileges:read write, group privileges:read only, everyones privileges:read only, file type:"osas", creator type:"ToyS", stationery:false, product version:"", version:""}
--For "system" owned items:
--> {class:document file, name:"com.apple.alf.plist", index:19, displayed name:"com.apple.alf.plist", name extension:"plist", extension hidden:false, container:folder "Preferences" of folder "Library" of startup disk of application "Finder", disk:startup disk of application "Finder", ... owner:"system", group:"root", owner privileges:read write, group privileges:read only, everyones privileges:read only, file type:missing value, creator type:missing value, stationery:false, product version:"", version:""}
end tell
For any user owned items AS returns the group name as “(unknown)”, except from keyboard with right click + Get info.
Please,
is anything wrong above? Am I missing something?
If not,Where is this “(unknown)” coming from? Is it a bug?
is there any AS, ASObjC, shell or GUI way to get the actual group name of items owned by a user?
My OS version is 10.11.3.