In article , Pedro
wrote:
> Hi people
>
> Please forgive me asking for someone else, but 'someone else' reckons
> they won't understand the answer, so ...
>
> My friend has just bought a MacBook Pro and tried to used the
> 'importing old files' utility to get the files from her old G4 PPC -
> via Firewire, I think.
>
> The files are there in the laptop, but she has to log out and change
> user to access them. Not handy!
>
> Is there an applescript that will change all the ownerships so she can
> open them in the normal way?
>
> I found this applescript:
>
> to chOwn(aliasToFolder)
> set mypath to quoted form of POSIX path of aliasToFolder
> set uName to do shell script "whoami"
> do shell script "chown -R" & uName & space & mypath & ";chmod 775 "
> & mypath with administrator privileges
> end chOwn
>
> which was quoted on:
>
> http://lists.apple.com/archives/applescript-users/2006/Aug/msg00255.html
>
> Will this do the trick? and if so ...
Well, it looks like it should do the trick of changing the owner of a
file to the current user. However, you will still need to write the
rest of the script -- the part that gathers the files that need their
owners changed, in whatever way you like, and passes them to this
handler.
> 1) Am I right she should edit this and replace "uName" with her login
> username (it's a single user Mac so she is also Admin)
The script uses the UNIX command whoami to figure out the username of
the current user, and sets the owner to that user. If you want to use
a different user than the current user, you could hard-code the name
instead of using whoami, or ask them to enter a user, etc.
> 2) Does she also have to replace "path" with something more specific,
> and if so, then what? [Sorry I'm vague on that path thing!]
No, the path is obtained from the alias passed in to the handler as a
variable. You just pass in an alias to the file you want to change.
> 3) Does this script (if appropriate) do the job by running, or should
> she drag-drop the folder with the files onto the script-app icon?
It works either way -- whichever way you write the rest of the script.
You could hard-code a list of files to have their owner changed, use an
Open dialog to select one or several, or accept files dragged onto the
icon -- however you want to do it. You just write the code to make it
work that way.
Is there any particular reason you want to do this with an AppleScript?
It seems the long way around. You can just open Terminal and do:
sudo chown -R `whoami` /Path/To/Folder
(You don't have to type the path to the folder; simply drag the folder
from the Finder into the Terminal window at this point in the command.)
After prompting for the administrator's password, this command will
change the owner of all the files in the specified folder to the
current user.
--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>
Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.