• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Possible to Get Property List Editor Edit Plist File?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible to Get Property List Editor Edit Plist File?


  • Subject: Re: Possible to Get Property List Editor Edit Plist File?
  • From: "(4) GMAIL 5278" <email@hidden>
  • Date: Wed, 9 Jun 2010 05:57:39 +0900

Thanks a lot.  I'll take a very close.


On Jun 9, 2010, at 5:52 AM, Luther Fuller wrote:

[OFFLIST]

On Jun 8, 2010, at 3:15 PM, (4) GMAIL 5278 wrote:

Dear AppleScriptors,

Hello.  I normally use Defaults to view and edit plist values if the list is not complicated.  When I want to access a value under an extensive array of strings, I don't know how to do it.  In one particular case, Apple's Property List Editor shows

At the end of March, this year, I replied to a similar question with the following:

Here's how I create a new preference file:

property defaultPrefsRec : {a:1, b:"string", c:{3, 4, 5}} -- for example
property prefsName : "prefsFileName" -- lookup info on CFBundleIdentifier to find out how to name your prefs file

set prefsFolder to (path to preferences folder from user domain)
set posixPath to quoted form of (POSIX path of prefsFolder)
do shell script "defaults write " & posixPath & prefsName & " x y" -- creates the new property list file with dummy value
tell application "Finder" to set prefsFile to (file (prefsName & ".plist") of prefsFolder) as alias
tell application "System Events" to set value of property list file (prefsFile as text) to defaultPrefsRecord


Reading the preference file:
tell application "System Events" to set prefsRec to (value of property list file (prefsFile as text)) --<<<<<<<<<<<<< READ

You can now modify the record prefsRec as desired.

Writing the preference file:
tell application "System Events" to set value of property list file (prefsFile as text) to prefsRec --<<<<<<< WRITE

Keep in mind that when you look at your preference file with Property List Editor, Array = list and Dictionary = record.

The current Property List Editor has a small idiosyncrasy that can be dangerous. When you open a plist file, "Show Raw Keys/Values" in the View menu is unchecked. You should always manually check it. This is not usually a problem for preference files, but it is a problem for an "Info.plist" file.

You can also read/write a key value in a .plist file using something like ...

value of property list item "nameOfItem" of property list file (prefsFile as text)

Notice, in all of the above, that prefsFile is an alias to a file. System Events requires a colon-delimited path to specify a file.


 _______________________________________________
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

References: 
 >Possible to Get Property List Editor Edit Plist File? (From: "(4) GMAIL 5278" <email@hidden>)

  • Prev by Date: Possible to Get Property List Editor Edit Plist File?
  • Next by Date: Re: AUTO: Bill Abt is out of the office. (returning 06/14/2010)
  • Previous by thread: Possible to Get Property List Editor Edit Plist File?
  • Next by thread: Re: Possible to Get Property List Editor Edit Plist File?
  • Index(es):
    • Date
    • Thread