Loop Apple Notes - Copy Apple Notes to MS OneNote

I'm new to Keyboard Maestro and have a rather conceptual question.
Background/requirement: I would like to copy the notes from an Apple Notes folder into a section in OneNote. I can copy a single Apple Notes page (with Action Move at found image) if both apps are opened correctly and I place the cursor in an AppleNote.
I also have an idea how I can open the right notebook and the right section in OneNote at the beginning (but it's more of a nice-to-have). But I have no idea how I should design the loop across all Apple Notes in a specific folder?
Thank you very much for tips/ideas
Andreas

The easiest way to work through a folder's contents in Notes is with AppleScript, getting the ids of all the notes in the folder then working through them one at a time. For each one you can then make sure the note (not the folder) is active, "Select All", "Copy", then switch to OneNote and do what you need there.

This will just make a new page for each note in the current section of your active notebook -- change the contents of the last Group of actions to suit your OneNote needs.

Notes to OneNote.kmmacros (9.8 KB)

Image

Thank you very much! I understand and it looks good to me. I'll try it out!

You could use "Shortcuts" to extract your notes from Apple Notes programatically.

Specifically 'Find Notes' (in folder)

These are all the actions you can perform on notes
image

Thanks a lot! I like "Shortcuts" - but I have no clue, how to loop through all notes of one folder with this...

I don't have onenote, but from what I've read it can be controlled via REST (even create notes)

So the entire process of extracting Apple Notes and creating MS OneNotes can be done via scripting, no UI necessary

For example, you can "Find all notes" in a folder of you choosing
then loop and 'open' each note (in notes) and then copy the note

Or, even better, you can extract the contents of the note and use OneNote's URL scheme to create a new note

Thanks for this approaches! But how to "mix" the Keyboard Maestro Actions with the first one? The second looks interesting and I will test it.

Just execute the KM macro after you open the note. It will wait until the macro is complete before returning to get the next item.

I think you really should play around with the shortcuts app a bit to learn it. It's really quite powerful

1 Like

What format are the note's contents copied in? I went UI for that stage onwards, rather than AppleScript, because both plain text and HTML were somewhat lacking compared to good ol' copy'n'paste.

Thank you - I will do!

Seems to be RTF.

If you 'save' the body of the note to a file in each step, you get an RTF file with NO images (that's the only difference I could tell between copy / paste in the UI and 'save to file' in shortcuts).

1 Like

I managed to do it with the Shortcut app! Thanks again for the fast answer!

1 Like