Action

Count words and drafts

Posted by David Blue, Last update over 2 years ago - Unlisted

A modified version of “Count words and drafts” by @scripts4drafts that includes some very specific personal modifications.

The original description:

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]]
  • twitter

    template
    [[result]]
  • file

    fileNameTemplate
    .txt
    folderTemplate
    template
    [[result]]
    `[[date|%m%d%Y-%H%M%S]]`
    ---
    local
    true
    writeType
    append

Options

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