How to append system clipboard in RTF format to RTF file (and preserve formatting of text and images)

I would like to be able to append styled (RTF) text + images to an RTF file, accumulating information as I am working on a project.

I like keyboard maestro and my 1st reflex was to create an empty RTF file and write a macro which when triggered would allow me to use the append system clipboard to RTF file action.

The problem is that the APPEND to file KBM action only allows for plain text which is useless for my purpose.
The KBM copy to file action works with RTF, but the file is overwritten with the last clip each time the macro runs, which defeats the purpose.

Is there a way around this preferably with KBM or any other method ?

I think the issue would be that RTF is content and structure whereas TXT is simply content. Appending to RTF would be a case of pulling off the structure at the end of the file and adding the new content, and then putting the structure at the end back on.

I think you would have to use something able to handle insertions rather than appends. I found this approach using Word, but I suspect similar would be possible with NisusWriter and similar too,

1 Like

I have no idea if this will work, but it’s an easy enough thing to try…

(MAKE SURE YOU HAVE A BACKUP or are testing on a document that you don’t care about, such as a duplicate.)

Instead of using Keyboard Maestro’s ‘append’ you could try a shell script which uses:

/usr/bin/pbpaste -Prefer rtf

such as

/usr/bin/pbpaste -Prefer rtf >>| "$HOME/Downloads/Bear Note Backups.rtf"

1 Like

thank you very much for your suggestion.

I ran a KBM macro with a single action: your shell script. It did not work.

The KBM engine log error message is pasted below. I don’t know anything about shell scripting.
Error with the pipe sign ?
All I can say is that I checked the file path and it is correct.

2020-07-30 21:34:23 text-script: line 1: syntax error near unexpected token |' text-script: line 1: /usr/bin/pbpaste -Prefer rtf >>| “$HOME/Downloads/Bear Note Backups.rtf”’

If you have any idea, I would be grateful. Thanks again

I will have a look. thank you