UPDATE: Works in Lion and Mountain Lion now too; see posts below.
Latest version maintained here: https://github.com/mbrowne/change-owner-osx-service
Using Snow Leopard's new Services feature, I created a service that allows me to change the ownership of files and folders from the Finder.
It lets you specify the owner (and also the group if you wish), and does the Terminal command for you (sudo chown....).
You can download the service here:
http://matthewhbrowne.com/software/change_owner_service.zip
Or if you'd rather do it yourself so you know how it works, here is the code:
And this is how you would set it up in Automator:
I hope this is helpful to somebody.
Also (this is unrelated), I created a service to generate HTML IMG tags for selected image files in the Finder. I tried to put it on automatoractions.com but the submission didn't take for some reason, so I've given up on that site.
I posted info on it here: http://macscripter.net/viewtopic.php?id=33267
Snow Leopard services are very cool, and if anyone knows someplace where they should be submitted so we can share and benefit from each other's services, let me know. It's too bad that it's so hard to get a submission in to automatoractions.com.
Latest version maintained here: https://github.com/mbrowne/change-owner-osx-service
Using Snow Leopard's new Services feature, I created a service that allows me to change the ownership of files and folders from the Finder.
It lets you specify the owner (and also the group if you wish), and does the Terminal command for you (sudo chown....).
You can download the service here:
http://matthewhbrowne.com/software/change_owner_service.zip
Or if you'd rather do it yourself so you know how it works, here is the code:
Code:
on run {input, parameters}
set newOwner to (short user name of (system info))
tell application "Finder" to display dialog "New owner/group
(Syntax: \"newowner\" or \"newowner:newgroup\")" default answer newOwner buttons {"Cancel", "OK"} default button 2
set newOwner to text returned of the result
activate --set the focus back on this Applescript so that when the authenticate box pops up it will have the focus
repeat with theFile in the input
set filePath to posixPath(theFile as text)
do shell script "sudo chown " & newOwner & " " & filePath with administrator privileges
end repeat
end run
--posixPath function by James Sorenson
--Source: http://hints.macworld.com/article.php?story=20011030193449870
on posixPath(mac_path)
set mac_path to (mac_path as text)
set root to (offset of ":" in mac_path)
set rootdisk to (characters 1 thru (root - 1) of mac_path)
tell application "Finder"
if (disk (rootdisk as string) is the startup disk) then
set unixpath to "/" & (characters (root + 1) thru end of mac_path)
else
set unixpath to "/Volumes:" & mac_path
end if
end tell
set chars to every character of unixpath
repeat with i from 2 to length of chars
if item i of chars as text is equal to "/" then
set item i of chars to ":"
else if item i of chars as text is equal to ":" then
set item i of chars to "/"
else if item i of chars as text is equal to "'" then
set item i of chars to "\\'"
else if item i of chars as text is equal to "\"" then
set item i of chars to "\\" & "\""
else if item i of chars as text is equal to "*" then
set item i of chars to "\\*"
else if item i of chars as text is equal to "?" then
set item i of chars to "\\?"
else if item i of chars as text is equal to " " then
set item i of chars to "\\ "
else if item i of chars as text is equal to "\\" then
set item i of chars to "\\\\"
end if
end repeat
return every item of chars as string
end posixPath
And this is how you would set it up in Automator:

I hope this is helpful to somebody.
Also (this is unrelated), I created a service to generate HTML IMG tags for selected image files in the Finder. I tried to put it on automatoractions.com but the submission didn't take for some reason, so I've given up on that site.
I posted info on it here: http://macscripter.net/viewtopic.php?id=33267
Snow Leopard services are very cool, and if anyone knows someplace where they should be submitted so we can share and benefit from each other's services, let me know. It's too bad that it's so hard to get a submission in to automatoractions.com.
Last edited: