Created
November 22, 2013 21:31
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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