Re: Fwd: Modifying a .plist file
Re: Fwd: Modifying a .plist file
- Subject: Re: Fwd: Modifying a .plist file
- From: John W Baxter <email@hidden>
- Date: Sun, 23 Feb 2003 20:43:41 -0800
- Envelope-to: email@hidden
If the file is located where the defaults command can operate on it
(eg...some .../Library/Preferences directory), and is formatted as a .plist
file (ie, a particular form of XML file), using the defaults shell command
would seem the safer way to go. One of its jobs is to change these things.
The original poster didn't give the name of the file or its location.
BUT...
Read the warning in man defaults about changing the file used by a running
application, and the possible corruption consequences of doing so.
It is likely that the file is in one of the right places and really is a
plist file as its name implies.
Start by going into Terminal and executing
defaults read whatever.you.found.the.name.of.the.file.to.be
but without including the .plist file name extension (or the directory path
leading to the file).
Does anything useful happen? The most useful would be a nice listing of
each setting, as is
[john@Zeus tmp]$defaults read com.apple.Terminal
{
AlwaysPromptOnQuit = 0;
AppleSavePanelExpanded = YES;
AutoFocus = YES;
Autowrap = YES;
Backwrap = YES;
Bell = YES;
....
lots more ...
}
At 20:18 -0700 2/23/2003, Michelle Steiner wrote:
>
Begin forwarded message:
>
>
From: Michelle Steiner <email@hidden>
>
Date: Sun Feb 23, 2003 6:31:57 PM America/Phoenix
>
To: "David R. Pierce" <email@hidden>
>
Subject: Re: Modifying a .plist file
>
>
On Sunday, February 23, 2003, at 05:08 PM, David R. Pierce wrote:
>
>
> I'm not an Applescript wizard or guru, I mostly just modify other
>
> people's scripts. I have never opened a file using Applescript
>
> (except to tell some program to do it). As for it always being in the
>
> same place, yes with the proviso that I don't know if .plist files can
>
> be modified by the author in future revisions. So how do I find the
>
> location of a number in a file? And half the time it will be the
>
> number 5, and the other half of the time it will be the number 17.
>
>
>
>
Well, you would have to visually inspect the file in a word processor
>
to determine the position of the number, and you would have to
>
determine whether the has a leading zero. Let's assume that the 5
>
doesn't have a leading zero, because that is harder. I created a dummy
>
file just for this example, with the 28th character as "5". This will
>
assume that the number will be either a one-digit number in the 28th
>
position, or a 2-digit number in the 28th and 29th positions.
>
>
--Michelle
>
>
property myPList : missing value
>
>
try
>
set myFile to (open for access myPList with write permission)
>
on error
>
set myPList to choose file
>
set myFile to open for access myPList with write permission
>
end try
>
>
set plistData to read myFile
>
set part1 to text 1 through 27 of plistData
>
if character 28 of plistData is "5" then
>
set part2 to text 29 thru end of plistData
>
set replacement to "17"
>
else
>
set part2 to text 30 thru end of plistData
>
set replacement to "5"
>
end if
>
set newText to part1 & replacement & part2
>
set eof myFile to 0
>
write newText to myFile
>
close access myFile
>
--
>
"There's some good in the world, Mr. Frodo, and it's worth fighting
>
for."
>
>
>
>
--
>
"There's some good in the world, Mr. Frodo, and it's worth fighting
>
for."
>
_______________________________________________
>
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.
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
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.