Re: Back Up Problems with Preference file
Re: Back Up Problems with Preference file
- Subject: Re: Back Up Problems with Preference file
- From: Kai Edwards <email@hidden>
- Date: Tue, 15 Oct 2002 10:56:14 +0000
on Tue, 15 Oct 2002 13:12:37 +1000, Michael STEINWEDE
<email@hidden> wrote:
>
I9m a new comer to AppleScript in OS X and have had very, very limited
>
experience of AS in OS 9.
>
>
I9m trying to backup my user files and it crashes on a preference file
>
called "com.apple.loginwindow.plist". When I check Show Info, it says the
>
owner is System.
>
>
When I temporarily move the file to the desktop and backed up the preference
>
folder, it backs up successfully. But I want to do back ups automatically
>
rather than manually moving and replacing this file each time.
>
>
I wrote this script, but I can9t even select the silly file, never mind move
>
it to the desktop.
>
>
tell application "Finder"
>
if file "com.apple.loginwindow.plist" of folder "Preferences" of
>
folder,
>
"Library" of folder "michaels" of folder "Users" exists then
>
say ("found it")
>
select "com.apple.loginwindow.plist" of folder "Preferences" of
>
folder ,
>
"Library" of folder "michaels" of folder "Users"
>
else
>
say ("can't find it")
>
end if
>
end tell
>
>
It keeps on coming up with this error message ...
>
>
Can9t get 3com.apple.loginwindow.plist" of
>
folder "Preferences" of folder "Library" of
>
folder "michaels" of folder "Users2. Access
>
not allowed.
This may not be as complicated as it might look, Michael. If the script is
as quoted above - and the error occurs at compile time, my guess is that
it's just a simple syntax error.
While your 'if exists' line refers to file "com.apple.loginwindow.plist" of
folder... (etc.), your 'select' line omits any mention of the required class
'file'.
Lengthy references like this can be confusing (to me, at least), so you
might like to consider using an alias instead. Since your script would keep
track of an alias, this should also remove the need for the 'if exists'
line.
To ensure accuracy, just run (in a separate script) the 'choose file'
command, point to the required file - and copy the result from Script
Editor's result window. Then paste it into a script that goes something like
this:
--------------------------------------------------
set theAlias to alias "path to:the item:you chose"
tell application "Finder" to select theAlias
-- do any other stuff with theAlias
--------------------------------------------------
As you may know, it's not usually even necessary to select a file to do
things with it. Instead, you can now simply refer to the variable 'theAlias'
(rather than 'selection' - which is what the Finder normally uses when a
script is recorded.)
For example, if I understand correctly what you're trying to do, something
like this might work for you:
--------------------------------------------------
set theAlias to alias "path to:the item:you chose"
tell application "Finder" to move theAlias to desktop
-- do backup stuff
tell application "Finder" to put away theAlias
--------------------------------------------------
HTH
Kai
--
email@hidden
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.