Re: Plist entry
Re: Plist entry
- Subject: Re: Plist entry
- From: Luther Fuller <email@hidden>
- Date: Sat, 19 Jan 2008 09:34:20 -0600
Here is a snippet of code that I use ...
tell application "System Events" -- read from Info.plist file in
bundleRef = source bundle
(item "Info.plist" of folder "Contents" of bundleRef) as alias
set InfoRecord to (value of property list file (POSIX path of the
result))
end tell
tell application "System Events" -- read ScriptBundleToolUserItems
in project.plist file
(item "project.plist" of contentsSource) as alias
POSIX path of the result
value of property list item "ScriptBundleToolUserItems" of property
list file the result
end tell
set InfoRecord to the result & InfoRecord
tell application "System Events" -- write to Info.plist file in
bundleRef = source bundle
(item "Info.plist" of folder "Contents" of bundleRef) as alias
set (value of property list file (POSIX path of the result)) to
InfoRecord
end tell
Notice that I use 'value' not 'contents'. In my code, 'InfoRecord' is
a record, not a list of records. You might want to try using 'value'.
And, yes, array = list and dictionary = record. When you read/write
'value' of the plist file, you are dealing with the 'root' dictionary/
record.
BTW, I've never used 'make new property list file ...'. Or, if I did,
I may have had a problem. I don't recall clearly. Does your use work
w/o error?
On Jan 19, 2008, at 8:41 AM, Axel Luttgens wrote:
On 19/01/08 14:18, Michael Ghilissen wrote:
This returns a list of records (hence: array -> list, dict ->
record); after some formatting, that list of records is:
So, as Luther already has outlined, one needs to build the list
with the records to be kept and save it back to a file.
For example, assuming you want to keep cookies related to "apple.com":
tell application "System Events"
set PL to contents of property list file "~/Library/Cookies/
Cookies.plist"
set PLValue to value of PL
set NewPLValue to {}
repeat with R in PLValue
if |Domain| of R ends with "apple.com" then set end of
NewPLValue to contents of R
end repeat
set NewPL to make new property list item with properties
{value:NewPLValue}
make new property list file with properties {name:"~/Desktop/
Cookies.plist", contents:NewPL}
end tell
Of course, there is sure more than one way to do it... ;-)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden