KM Dictionary as Plist

Overview

Action: This action will either take the contents of a Keyboard Maestro dictionary and save the data to a file; or read the contents of a file and import those data to a Keyboard Maestro dictionary. The file can be of either Plist or JSON format.

Input: Either a full path to the file is supplied, or a path to a folder. The latter is preferable, as the filename will be automatically determined using the name of the dictionary—supplied in the field labelled Dictionary—and the selected format of the file (.plist or .json), chosen from the dropdown list labelled Format. The default is Plist. The Mode determines which direction the data travels: GET (default) reads data from a file and imports it into a KM dictionary (note that the file must exist); SET exports a KM dictionary, saving it to a file (note that the KM dictionary must exist).

Output: In GET mode, the contents of the KM dictionary are returned after retrieving the data from a file and importing it into the dictionary. It is returned in an stringified version of an AppleScript record object. In SET mode, the full path to the file is returned after the KM dictionary has been exported. This result may be ignored, displayed in a window, displayed in a notification, saved to a variable, or copied to the clipboard.


KM Dictionary As Plist.zip (52.2 KB)

7 Likes

I just delved into dictionaries today to store/retrieve client information and this plugin is great! My main dictionary has over 260 entries (probably small compared to other users here), and the ability to save it as a file so 1) it will sync between computers and 2) to be able to modify it in BBEdit is invaluable.

In my opinion, would be better to modify it as JSON. Use the JSONFromDictionary token.

Also, I have a really good dictionary editor in my Variable Inspector Prompt. You can also easily get the JSON from it if you prefer to edit it that way, and you can set the dictionary to JSON also.

1 Like

Hey Dan, I'll look into that for sure because initially I was trying to figure out how to read and write a KM dictionary from/to a file I have saved in Dropbox (this is important because I want the dictionary accessible from two computers) using only KM native actions.

I was able to set the KM dictionary from the file using two actions: read file to system clipboard, and then settings dictionary to json using the system clipboard token. But I wasn’t able to figure out how to set the KM dictionary back to that file using native actions. Since I wanted to get my new dictionary up and running in my macro right away I am using this plugin, but I am all for learning other methods to modify and store dictionaries remotely.

FWIW, I used your VIP extensively while setting up my dictionary. It was invaluable!

1 Like

Awesome! Thanks for letting me know.

I think you've got it figured out now, but if not:

image

Let me know if you still have questions.

2 Likes

Perfect, that is very helpful. That %JSONFromDictionary%% was the missing link, thanks again Dan!

2 Likes