Search code examples
macosterminalplist

change plist dic/string via osx-terminal


I'm trying to change two sting keys within a dictionary plist file with the os x onboard tools (via terminal) but I'm having problems. I just switched back to os x after a 10 years break so I'm struggling a bit atm.

plist data

% plutil -p "/Users/username/Library/Preferences/com.Adobe.Common 15.0.plist"                                                          
    {
      "Media Cache" => {
        "DatabasePath" => "/Users/path/somewhere/one"
        "FolderPath" => "/Users/path/somewhere/two"
      }
    }

I tried several command wiht defaults write, plutil & PlistBuddy but I'm not able to change the values to anything else.

% defaults write "/Users/username/Library/Preferences/com.Adobe.Common\ 15.0.plist" "Media Cache" -array-add '{DatabasePath = (test);}'

Could someone help me with this problem? The empty spaces aren't perfect but I have to deal with them...

Best, Ben


Solution

  • Using defaults you can change or set your keys this way

    defaults write ~/Library/Preferences/com.Adobe.Common\ 15.0.plist "Media Cache" -dict DatabasePath "/Users/path/somewhere/one" FolderPath "/Users/path/somewhere/two"
    

    From man

     -dict       Allows the user to add a dictionary to the defaults database
                 for a domain.  Keys and values are specified in order:
    
                       defaults write somedomain preferenceKey -dict key1 value1 key2 value2