Skip to content

Instantly share code, notes, and snippets.

@craSH
Created November 22, 2013 21:31
Show Gist options
  • Save craSH/7607242 to your computer and use it in GitHub Desktop.
Save craSH/7607242 to your computer and use it in GitHub Desktop.
Convert given plist file in-place from binary to XML or XML/JSON to binary.
#!/bin/bash
# Convert given plist file in-place from binary to XML or XML to binary.
file -bI "$1" | grep -q '^application/octet-stream'
if [ $? -eq 0 ]; then
# Binary plist - convert to XML
plutil -convert xml1 "$1" || echo "Failed to convert $1 to XML." >&2; exit 1
echo "Converted to XML: $1"
else
# XML or JSON - convert to binary
plutil -convert binary1 "$1" || echo "Failed to convert $1 to binary." >&2; exit 1
echo "Converted to Binary: $1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment