I wish there were a script in DT that would convert Pages documents to Markdown. Ideally, I’d import hundreds of Pages documents into DT and have it convert them to Markdown for import into Ulysses or Finder for use with another Markdown editor.
I know nothing about scripting and won’t even attempt it.
Does anyone know of a way to bulk convert Pages documents to Markdown? I don’t care about tables and images; I only need the text reasonably formatted in Markdown.
You could ask Claude for an Apple script to convert pages documents to word. Then use pandoc. But make a copy of your pages files first before using AI generated scripts.
Claude will write the script for you. I know because I just asked! I don’t use Pages, so that exact script isn’t relevant for me, but I do a lot of document conversion and when I saw your post it occurred to me that it might be easier to convert files in Devonthink rather than use Pandoc.
I haven’t tested the script yet, though—so it may have bugs. The script converts the selected document to Word, then converts it to Markdown using Pandoc. I was also offered a script that would run automatically every time a file was added to a specified folder in DT.
@dque and @krocnyc, thank you. I understand that Claude could write a script, but the reality is, I wouldn’t know how to use it if I had it. Ideally, I could add such a script to DEVONthink, import the Apple Pages documents, and run the script to convert them to Word or markdown. Do you happen to know if that’s possible? If so, I could try it on a few documents to see how it works. It would be fantastic if I could do that!
Claude will tell you! I asked for specific instructions on how to use the script with DT, and got them.
That is exactly what Claude says the script will do. I gave me two options: 1) a script I could trigger manually once the files were in DT and 2) a script that would run automatically when files were added to a specified folder in DT.
Like I said, I haven’t tried using it, so it may not work as advertised, but I’m guessing that with some back-and-forth with Claude, you should be able to build something that does what you want.
PS: I think you’ll get the best result if you tell Claude exactly what you want to do and why. Outline your ideal workflow step-by-step, but let Claude know you’re open to alternatives if your proposed workflow isn’t feasible or the best option. Ask Claude to be open when it can’t provide an answer.
@Bmosbacker I know some scripting and terminals can be a bit intimidating. As @krocnyc said, have a bit of a conversation with Claude about it. DT can run Apple Script. But I do not quite know how that works.
I would do the following: make a test folder and discuss with Claude a way of converting files. When Claude gives you a script, cross check it in a new chat or elsewhere like ChatGPT to see that it does not do anything dangerous. If it is ok (most likely the case), try it on the test folder and see what happens.
It might take a bit of tinkering, but I think it is no worse than tinkering with any GUI. I think you will find using your own Claude augmented scripts rewarding. To me command line tools often feel like a divine power (“He said let them convert and they converted”). DevonTHINK might actually serve as a great platform to have some kind of a launcher for scripts.
Here are the instructions Claude provided with its response to my prompt:
To use in DEVONthink:
Open Script Editor and paste the script
Save as “Convert Pages to Markdown” in ~/Library/Application Scripts/com.devon-technologies.think3/ (or add via DEVONthink’s Scripts menu)
In DEVONthink, select one or more .pages files
Run the script from Scripts menu
What it does:
Exports each Pages file to DOCX format temporarily
Converts DOCX to Markdown using pandoc
Imports the resulting .md file into the same DEVONthink location as the original
Cleans up temporary files
Next steps we could explore:
Modify the script to delete original Pages files after conversion
Add options to preserve or extract embedded images
Create a batch processing version that works on entire folders
Adjust pandoc conversion settings for different Markdown flavors (GitHub, CommonMark, etc.)
Claude also told me that I’d need to download and install Pandoc for the script to work and suggested I use Homebrew to do so. I asked it what Homebrew is, where do I get it, and how do I use it. It gave me detailed step-by-step instructions on how to access it and use it. It also told me that if I didn’t want to use Homebrew, I could download the installer version directly from the Pandoc website.
In my experience, Claude and Gemini are both quite accommodating when you ask for help. Since they’re tuned to foster engagement, they never get weary of holding your hand when you try to do something completely out of your wheelhouse.
I just tried pulling a script together to do this: I have a number of Pages documents myself and it would make my life simpler if they were simply markdown files.
That noted, Apple has overly complicated the “scripting” aspect of macOS: AppleScript, Shortcuts, Automator. It actually makes me long for the day when AS was the only option and someone like me only had one wall to bang my head against, not multiple.
I want to be clear: I bought any number of AppleScript books and I never quite grokked it. (I could figure out Python, but not AppleScript!) So I welcomed the lego-block approach to programming promised by Automator and, later, Shortcuts. I thought it would make things easier for a midwit like me. Nope, nope, nope.
FWIW, the only way I’ve found is cloudconvert.com. It is an online conversion service that can be run as a google workspace add-on. But I’ve never used this.
It does not do Pages to markdown but does convert pages to docx which can then be download from google drive as markdown.
You can also simply export a document from Pages in Word format—no need to rely on a cloud service for a Pages to Word conversion, especially if you’re concerned about privacy.