Action

Export Review Draft

Posted by viticci, Last update about 6 years ago - Unlisted

This action exports drafts that match specific tags and have not been archived. Drafts are then compiled into a single .md file that is saved in iCloud Drive, backed up to Dropbox, and shared with the system share sheet.

You should change the tag name (currently set to ‘ios12’ and ‘compile’) in the first Script action, and change the paths and file names in the other actions to match your needs.

Steps

  • script

    var drafts = Draft.query("", "all", ["ios12", "compile"]);
    
    //Sort matched notes by title
    
    drafts.sort((a,b) => {
    return a.content.localeCompare(b.content);
    });
    
    //Create empty sections variable and iterate over notes to add them to the variable
    
    var sections = [];
    
    for (var i = 0; i < drafts.length; i++) {
    	item = drafts[i];
    	if (!item.isArchived){
    		sections.push(item.content);
    		sections.push("\n\n");
    	}
    }
    
    var compile = sections.join("");
    
    //Create first backup in Drafts 5 folder in iCloud Drive, runs in the background
    
    var fmCloud = FileManager.createCloud(); // Cloud file in app container
    var success = fmCloud.write("/Review.md", compile);
    
    draft.setTemplateTag("file", compile);
  • dropbox

    fileNameTemplate
    Review.md
    folderTemplate
    /Review/
    template
    [[file]]
    writeType
    replace
  • openIn

    No preview available.

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.