2016-11-06 75 views
0

使用AppleScript,我如何編輯密鑰PhoneNumber到一個新的值並刪除密鑰UserActiveAppleScript代碼來編輯我的plist

我已閱讀蘋果的文檔,但我沒有得到任何成功。感謝幫助。

<?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

爲編輯plist文件它更簡單的使用/ usr/libexec目錄/ PlistBuddy在腳本中你可以與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. 

一個例子在終端窗口看到:控制器:IOPCIMatch從AMD5000Controller.kext或AMDRadeonX3000.kext

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 
+0

告訴應用程序 「終端」 \t \t activate \t \t do script「/ usr/libexec/PlistBuddy -c \」Print:IOKitPersonalities:Controller:IOPCIMatch \「/System/Library/Extensions/AMD5000Controller.kext/Contents/info.plist;在/ usr/libexec目錄/ PlistBuddy -c \ 「打印:IOKitPersonalities:AMDCedarGraphicsAccelerator \」 /System/Library/Extensions/AMDRadeonX3000.kext/Contents/info.plist 「 \t \t \t年底告訴 – deek5

+0

好吧,我試試這個。感謝您的關注 – robert

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 
+0

在終端窗口中看到的一個示例控制器:AMD5000Controller.kext或AMDRadeonX3000.kext的IOPCIMatch IOKitPersonalities – deek5