I tested the scripts before posting and they did work. However, I was not starting from RTFD files. This is quite a key aspect to to leave out! Also the fact that you are first exporting from somewhere else means that there is potentially more automation that could be done. Do please consider sharing all the details when posting a query. Irrelevant information is easy to discard, but relevant information can’t be made up.
Bear does not have AppleScript support, but it does have Shortcuts support, so you could potentially even start from there in your automation to export to RTFD and pass that on to another stage in your conversion process.
That’s where I’ve picked it up as I could bundle that into something and let you pick it apart and build it out from there (remember that Shortcuts supports running AppleScript and calling scripts at the command line (AppleScript can be run at the command line).
I’m not at all fond of AppleScript, but it does seem to be the best option for doing the conversion with Pages, and unfortunately textutil
and pandoc
are not helpful in this case as far as I can tell. So I persisted and cobbled together something that seems to work for a test note I’ve exported from Bear as RTFD and then used this AppleScript to convert automatically into a Pages format document. There was some interesting research along the way because Pages has an issue where it throws up permissions errors when trying to export via AppleScript - an issue that’s apparently been around since 2017 at least. Fortunately, someone had come up with a clever workaround.
The resulting script I’ve built into an Automator workflow set as a Quick Action. You can download it here as a ZIP file. Unzip it and copy the workflow file into your Services
directory (~/Library/Services/RTFD to Pages.workflow
). Then make sure it is enabled in Settings (App) > Extensions > Finder.
In Finder, right click on your RTFD, and select “RTFD to Pages”. With any luck (maybe after a few permissions prompts), you should get a .pages version of your file in the same directory. The original RTFD is left in place.
Here’s how the automation and script look.
Maybe there’s a better way? As I noted, AppleScript isn’t really my favourite as I have more of a traditional developer background so it doesn’t gel with me the way most other types of languages do. There may be issues with it, but honestly it’s the best first stab I can make at something that I would have expected to be a lot simpler than it turned out to be. I’ve also carried out a very limited simple file test (though the file did contain both images and text).
Give it a try, and let us know if it works or if this leads to any other issues.