How do you set an item in a .plist with PlistBuddy?
Asked Answered
A

2

5

I'm having trouble tracing through a .plist with PlistBuddy and change it in the command line, I know the format is similar to, "/usr/libexec/PlistBuddy -c "Set :items:2:assets: www.test.com" ./Test.plist" But I keep getting an error of Does not Exist. What would the path be to change url?

<dict>
  <key>items</key>
  <array>
    <dict>
    <key>assets</key>
    <array>
      <dict>
        <key>kind</key>
        <string>software-package</string>
        <key>url</key>
Abebi answered 19/6, 2013 at 15:38 Comment(0)
P
7

You can use :items:0:assets:0:url

Patric answered 19/6, 2013 at 15:58 Comment(1)
my .plist is :<array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>123</string> </array> </dict> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLName</key> <string></string> <key>CFBundleURLSchemes</key> <array> <string>abc</string> </array> </dict> then I run /usr/libexec/PlistBuddy -c "Set :CFBundleURLTypes:0:CFBundleURLSchemes. It returns Set: Cannot Perform Set On ContainersDabney
C
0

escraffod's solution worked for me.

Here's the complete solution for the problem:

/usr/libexec/PlistBuddy -c "Set items:0:assets:0:url http://www.test.com" ./Test.plist

Concertize answered 19/11, 2015 at 20:46 Comment(1)
my .plist is <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>123</string> </array> </dict> then I run /usr/libexec/PlistBuddy -c "Set :CFBundleURLTypes:0:CFBundleURLSchemes It returns ``` Set: Cannot Perform Set On Containers ```Dabney

© 2022 - 2024 — McMap. All rights reserved.