514 Views 3 Replies Latest reply: Oct 25, 2006 9:22 AM by jbarros
HAve a look at Late Night Software's "Property List Tool" (http://www.latenightsw.com/freeware/PListTools/index.html). It is very easy to use and quite reliable, with no or minimal learning curve.
Hope this helps!
Property list files are a specific type of XML document although in Tiger they are often stored in a binary format. You may want to look at Apple's Property List Programming Guide or Apple's DTD (Document Type Definition) for property lists (if you understand how to read a DTD).
The "defaults" command line tool can be used to read/write plist files as long as you don't have to deal with complex nested structures. So it may be useful in your script.
There's also a command line utility that comes embedded inside some of Apple's installers called PlistBuddy. You probably have some copies of this utility inside some of the installer receipts left behind in your /Library/Receipts folder. Executing PlistBuddy with a "-h" option will print out some usage information. For example:
The defaults command can access a property list file either as an XML text file or as a binary file... I'm not sure about PlistBuddy as I've never had a reason to use it.
If you have installed the Xcode Tools you'll also have Property List Editor (in /Developer/Applications/Utilities). Property List Editor is a GUI app that you can use to read/write plist files. It may be useful if you need to tinker with a plist file interactively, but it's probably not much use for scripting.
You can also use the "plutil" command line tool, if needed, which allows you to convert a binary plist file into an XML text file. You can then manipulate the text file with other text processing tools and use plutil again to convert back to binary.
If you need to work with complex or deeply nested data within the plist file then the defaults command may not be capable of doing it. You could potentially write a Cocoa tool that makes use of an NSDictionary/NSMutableDictionary to manipulate the plist data. The NSDictionary class in Cocoa makes it very easy to read/write a property list file with a single line of code. Once you've read the plist file into an NSDictionary you can use all the various class/instance methods to manipulate the dictionaries structure and data.