Export multiple drafts as individual text files


Is there a straightforward way to export a selection of drafts as individual text or MD files to Files or Dropbox? I don’t know how to split the JSON or CSV file back into individual files.

I have about 450 entries that I want to export.

I’ve hunted around, because this seems to be something that should be self-evident. But apparently not.


I would suggest a script for this - to be executed as a Drafts action. Something along the lines of:

let fmCloud = FileManager.createCloud();
let yourFolder = 'YOUR_FOLDER';
fmCloud.createDirectory(yourFolder, "/");

let draftsGroup = Draft.query(YOUR_QUERY_HERE);
draftsGroup.forEach(function(myDraft) {
    fmCloud.writeString(myDraft.processTemplate('safe_title') + '.md', myDraft.content);

You’ll need to define the query - https://reference.getdrafts.com/objects/Draft.html, and specify your folder. This saves to iCloud.

I’ve not had time to test my code, but it should hopefully point you in the right direction.

Alternatively, press and hold on the select button on iOS, and then execute one action on all of the selected drafts (every draft in your current workspace view will be selected). In hindsight that’s probably easier than the code I thought up :laughing:


Thank you for the generous help, Rosemary. And yes, I’d already concluded that I could do what I wanted through an action on a multiple selection, and did so. But i appreciate the script suggestion.