Re: create a new plist item using applescript
Re: create a new plist item using applescript
- Subject: Re: create a new plist item using applescript
- From: Luther Fuller <email@hidden>
- Date: Sun, 10 Dec 2006 16:27:46 -0600
Here's a snippet I wrote not long ago while trying to get my Dock to
behave the way I wanted.
-- newRecord is a record of keys to be written to
"com.apple.dock.plist"
-- the keys may not yet exist in the file
set prefsFile to (path to preferences from user domain) as text
bundle identifier of (info for (path to application "Dock"))
tell application "Finder" to set prefsFile to (prefsFile & the
result & ".plist") as alias
tell application "System Events"
sey dockPath to (path to prefsFile)
value of property list file dockPath -- entire plist file as a record
set dockRec to newRecord & the result -- the modified record
set (value of property list file dockPath) to dockRec -- write new
contents
end tell
Do not use ...
set dockRec to the result & newRecord
The order of concatenation will not write new values when the keys in
newRecord do already exist.
On Dec 10, 2006, at 2:44 PM, Mike Silva wrote:
I would like to modify an existing plist file by changing some
existing plist items and adding some new ones.
Modifying existing plist items works fine using syntax like:
osascript -e"tell application \"System Events\" to set value of
property list item \"CFBundleSignature\" of contents of property
list file \"blah.plist\" to \"Something\""'
but this syntax fails if I try to add a new element to the plist.
(I get this error):
36:168: execution error: System Events got an error:
NSReceiverEvaluationScriptError: 4 (1)
How can I create a new plist item to an existing plist?
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden