How to read the content of a key in a plist?

I'm trying to read the content of the key 'projectdirectory' in a plist. Currently I have a clumsy approach with BBEdit. I'd prefer a smart solution, preferably one that runs in the background. All I need is the string '/Users/hl/Dropbox/CT/Pro/abc/abc2023-07-20-2'.


How can I tackle this?

Test - Get current CafeTran Espresso project.kmmacros (17.8 KB)

This is the parent of the key:

Hey there, it looks like you’re already familiar with RegEx, so that’s good (I did adjust the RegEx in my example a little though). All you really need to do is use the read a file action to get that file’s contents into a variable (or clipboard if you prefer)... for instance, see my example below. ↓

Read a plist file and extrat key value.kmmacros (2.5 KB)

Macro screenshot (click to expand/collapse)

I know there are other ways to do it... like using the command line’s plutil command, but that’s probably overly complex for what you need and I’m not as familiar with it anyway.

1 Like

Thank you, Chris. Unfortunately, I get this error:

Ok, that makes sense. I forgot about not being able to read a plist file directly from that action. My apologies. So then try the following. It uses the plutil command line tool I mentioned earlier. Just verify that the file path to your plist file in question is correct in the shell script action.

Read a plist file and extract key value.kmmacros (3.3 KB)

Macro screenshot (click to expand/collapse)


Thank you, Chris! With your help I created this solution:

And finally I created this macro:

Write all unique text strings in target segment to the project's user-dic.kmmacros (17.0 KB)

Great, glad you were able to adapt it to your needs!

1 Like