Action

Count words and drafts

Posted by @scripts4drafts, Last update over 2 years ago

From time to time, I launch this action to know what’s under the hood in Drafts : it counts the words, drafts and words per draft in average.

Steps

  • script

    let n = 0, w = 0;
    const allDrafts = Draft.query('', 'all');
    for (let d of allDrafts) {
      w += d.content.split(/\s+/).length;
      n++;
    }
    draft.setTemplateTag('result', `Counted ${w} words in ${n} drafts. It's ${Math.round(w/n)} words per draft in average.`);
  • insertText

    template
    [[result]]

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.