使用AppleScript,如何将键PhoneNumber
编辑为新值并删除键UserActive
?
我已阅读Apple的文档,但我没有取得任何成功。谢谢你的帮助。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Person</key>
<dict>
<key>Adult</key>
<dict>
<key>Names</key>
<dict>
<key>MyName</key>
<dict>
<key>Adress</key>
<dict>
<key>Profissional</key>
<dict>
<key>CelNumber</key>
<integer>4</integer>
<key>PhoneNumber</key>
<integer>5</integer>
</dict>
<key>UserActive</key>
<integer>0</integer>
</dict>
答案 0 :(得分:0)
对于编辑plist文件,使用PlistBuddy可以更简单地在脚本中使用/ usr / libexec / PlistBuddy
Clear type Clears out all existing entries, and creates root of type
type. See below for a list of types.
Print [entry]
Prints value of entry. If an entry is not specified, prints
entire file. See below for an explanation of how entry works.
Set entry value
Sets the value at entry to value.
Add entry type [value]
Adds entry with type type and optional value value. See
below for a list of types.
在终端窗口中查看的一个示例:控制器:来自AMD5000Controller.kext或AMDRadeonX3000.kext的IOPCIMatch
tell application "Terminal"
activate
do script "/usr/libexec/PlistBuddy -c \"Print :IOKitPersonalities:Controller:IOPCIMatch \" /System/Library/Extensions/AMD5000Controller.kext/Contents/info.plist;
/usr/libexec/PlistBuddy -c \"Print :IOKitPersonalities:AMDCedarGraphicsAccelerator\" /System/Library/Extensions/AMDRadeonX3000.kext/Contents/info.plist
"
end tell
答案 1 :(得分:0)
tell application "Terminal"
activate
do script "/usr/libexec/PlistBuddy -c \"Print :IOKitPersonalities:Controller:IOPCIMatch \" /System/Library/Extensions/AMD5000Controller.kext/Contents/info.plist;
/usr/libexec/PlistBuddy -c \"Print :IOKitPersonalities:AMDCedarGraphicsAccelerator\" /System/Library/Extensions/AMDRadeonX3000.kext/Contents/info.plist
"
end tell