PlistKeyMod.sh is used to both extract and modify the values of specific keys in a plist file.
/PlistKeyMod.sh -f="$HOME/Desktop/example.plist" -k="CFBundleName"
This will return the value of the key "CFBundleName".'
/PlistKeyMod.sh -f="$HOME/Desktop/example.plist" -k="CFBundleName" -m="write" -v="Example"
This will change the value of the key "CFBundleName" to "Example"
This option chooses what file to perform actions on.
Example: /PlistKeyMod.sh -f=example.plist
This option chooses what key to perform actions on.
Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName
This option chooses what mode to use when performing actions on a file.
Available modes: 'read' and 'write'
If the mode is 'write', use -v to choose what to write.
Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=read
This option chooses what value to assign a key if mode is set to 'write'.
Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=write -value=StringToAssign
This option chooses where to send the result.
There are three modes that the output option can handle. These are 'auto', 'STDIN', and 'filepath'
The option 'auto' will print the result to stdin if the mode is read and will edit the file if the mode is write. The option 'STDIN' will cause any result to be printed to stdin, even if the mode is write. The last option is dynamic. Any absolute filepath ented will cause the script to print all result, except error messages, to the supplied path.
Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=write -v=StringToAssign -o=STDIN
This will cause the whole plist file to be returened to stdin, but with changes made.
Example: /PlistKeyMod.sh -f=example.plist -k=CFBundleName -m=read -o=/tmp/result.txt
This will send the value of the key 'CFBundleName' to a file in /tmp/result.txt
0: Success
1: No file supplied.
2: Specified key was not found in the file.
3: Specified file does not exist.
4: Unsupported mode recived.
5: Specified file is not plist.
6: Unknown argument recived.