How to Convert plist Files to XML or Binary in Mac OS X
5 stars based on
I stumbled over these option this morning. I do not know when they were introduced, but I can see the options in You can see them yourself with plutil -help.
Its main use up to now was to convert between property list formats mainly from binary plists to something readable. On Sierra, when you run plutil -help you see some new options. These allow you to directly manipulate keys and values in a property list. This may be useful to replace Binary plist command line and defaults to manipulate property lists. When testing binary plist command line I noticed one downside of plutil immediately: Copy this to create an empty plist file:.
This uses a non-standard output format, and the help text warns to use this parse plists. But it will do to look at the content. It looks like -extract is meant to get values from a property list, but there is caveat. Binary plist command line by default if you do not provide an new output file path with the -o option it will overwrite the current file with the extracted data. This will print a full property list file to stdout.
The -o - option tells plutil to print to stdout. You can give a filename instead of the. Since the output is encumbered with the json or xml syntax, it will be binary plist command line to use this to get to property list values in shell scripts. However, binary plist command line still may be useful to, well, extract property list data from a complex plist file. Keep in mind that there now is an alternative to defaults and PlistBuddy.
Not having to convert a plist before changing data might be helpful, as well as the possibility to manipulate arrays and dictionaries with binary plist command line paths. You still should always use defaults when working with preference plist files, since defaults will go through the preferences system and possibility notify a process to update data.
If you are using python or a similar high level scripting language it will still be more effective to use the libraries for property lists. Did you come across anyway of working with deeply nested keys and values with plutil? I think PlistBuddy is better in this case, since the output of plutil is a full xml plist in itself and harder to parse.
Howevershould the order of the items in either the Accounts array or the Services array change you binary plist command line be messed up. Arrays should preserve order in property lists, but it might be that the process which writes these arrays binary plist command line not care.
You should at the very least verify that: Your email address will not be published. Notify me of follow-up comments by email. Notify me of new posts by email. Copy this to create an empty plist file: Inspecting a property list You can use the -p option to check our progress: Modifying values You can modify values with the -replace option. Deleting values Very straightforward: The proper, non-destructive syntax to use -extract is: Conclusion Keep in mind that there now is an alternative to defaults and PlistBuddy.
Or a Swift tool. Leave a Reply Cancel reply Your email address will not be published. Prepare for autopkg Recipe auditing.