pltool - Command line interface to property list files, useful for scripting.

Syntax

   pltool [--version | --credits | --help]
   pltool <path> [get | exists | type | delete | count | keys] <keypath>
   pltool <path> set <keypath> <value> {<type>}

<path>is a full or relative path to a plist file (eg. "foo.plist").
<keypath>is a string that specifies a path to a property list member, using C-like syntax for arrays and dictionaries. Keypaths can be null or omitted if the root plist item is not a dictionary or array. This is admittedly rare. See examples.
<value>is a string value to be written to the specified property list key.
<type>is an optional tag that indicates what type the value string should be interpreted as. Values are -string (the default), -integer, -float, -boolean, -data, and -date.
<options>is additional flags depending on specific command. The only option currently defined is:

-zone <timezone>

Where <timezone> is a Time Zone name or abbreviation or the value 'system' which uses the system time zone.

Return Codes

pltool returns 0 on success and other values on failure.

Commands

getRetrieves the value at the keypath and writes it to standard output.
existsTests if a value exists at the keypath. Returns 0 if so.
typeIf the keypath exists, writes one of the following strings to standard output: Array, Boolean, Data, Date, Dictionary, Number, String.
delete  Removes the value at the keypath.
countIf the value at the keypath is an array or dictionary, writes the number of elements contained within the structure.
keysWhen the value at the keypath is a dictionary, writes a space-separated list of the dictionary's keys to standard output.
setSets the value of the item at keypath to the specified value (and type, if specified. Intermediate values are created if necessary, including array elements.

Notes

Examples

pltool foo.plist set MyDictionary.MyArray[3] 3.14159 -float

Creates foo.plist if necessary, and a nested dictionary and array and stores the value 3.14 as a floating point value in the fourth array element (the first three elements are null strings.

pltool foo.plist count MyDictionary.MyArray

Writes the number of elements of MyArray to stdout. (Will be 4 after earlier command.)

Version History

Download

pltool.zip version 2 (28 KB).

© 2005-2006 by Brent Marykuca. You are free to use and redistribute this program in any way you wish. This work is distributed on an "as is" basis without warranty of any kind. Please report bugs to the address given in pltool --credits.