Text "Doesn't" End With

I spend years using KM only for AppleScript I didn't realise there were a lot of handy options...

I'm trying to save every clipboard which matches some conditions.

Triggered by the system clipboard change.

then I have a few conditions such
Trigger Clipboard contain ....

What I would like to know:

I would like to use "NOT" end with but It seems that this option is missing and I only have "end with" as a condition

Can I also use the number of lines in the clipboard as a filtering option? e.g if line =< 6 then...

I'm also trying to add all the content to a text file (ideally it would purge every day but I'll look into that after) I selected:

  • Append Trigger Clipboard to File
  • Append Trigger Clipboard

But somehow the new clipboard overwrites the whole text file and remove previous contents.

This part is resolved somehow.

Finally, is that taking a lot of system resources to look and filter through the clipboard all the time?

I think you can use either of the two:

  1. Condition: "Text end with" is not true.
  2. Condition: Text does not match and use RegEx.
1 Like

You can use this Shell script to get the line count:

wc -l <<< "$KMVAR_LocalVar"

1 Like

Answered by @martin.

Use the Filter action with the setting to "count the lines" to set a KM Variable, say "Local__NumLines".
Then use the If Then Else action with Calculation condition of Local__NumLines ≤ 6

Use the Append Text to a File action.

Sorry in advance if what I say sound stupid, but the thing is I need all this 5 conditions to be true, and only the last one (not on the screenshot yet) to be not true.

But I don't see a way to force the 5 previous statement to be true and only the last one false

Then the 2nd method (does not match) I mentioned will work:
You did not give specific information, such as "Not end with" what? I can only give a general example.

1 Like

Thanks a lot, that seems perfect, I'll try that in a minute.