Pulling variables from a text file to file an invoice in DEVONthink

I am using the work of @JimmyHartington in Pulling in Variables from a .CSV File to Use in Mail Merges to design this macro. It still does not work, but I think I am close. I could not use a csv file because my Mac automatically turned it into a numbers file. So I used to text file. Here is an example of the text file: Bappa,x-devonthink-item://8AE4860A-8D6B-4F01-9362-716283374302,Bappa

I want to file an invoice in DEVONthink. Here is the macro that doesn't work.

2aa patient invoice.kmmacros (3.9 KB)

In the example, I'm giving you Bappa is the first name that I'm using. This action identifies how I get that first name.

Honestly, I don't understand how this works completely. I'm guessing that the action below doesn't correspond well enough because it's really not a series. AI says case does not matter.

1 Like

Have you read the file into the csvline variable?

As you can see from your action, the csvline variable is not matching your regex.

The second line of this:

...is wrong.

To access KM variables in your shell script you use the pattern $KMVAR_variableName, so that should be

grep -i "^$KMVAR_First_Name,"...

Make sure you have allowed Notifications from both Keyboard Maestro and Keyboard Maestro Engine so that you see error Notifications when your scripts fail.

Your macro should then work without the extra Actions you've pictured.