Action

Tag drafts by hashtag

Posted by derekvan, Last update almost 6 years ago

This script looks for drafts in the inbox that have hashtags in their content, then adds a drafts tag based on the hashtag. Thanks to kjaymiller for the original script I built on.

Steps

  • script

    // This script builds on kjaymiller script to find hashtags inside drafts by looking not just at current draft, but all drafts in inbox. Original script: http://actions.getdrafts.com/a/1ME
    
    
    // Get all the tagged drafts in the inbox
    var taggedDrafts = Draft.query("", "inbox");
    
    // find tags in content
    var re = /#[\w\d]+/g;
    
    // Tag drafts
    for (var i=0; i<taggedDrafts.length; i++) {
    	var tags = taggedDrafts[i].content.match(re);
    	for (tag in tags) {
    taggedDrafts[i].addTag(tags[tag].substring(1));
    }
    	taggedDrafts[i].content;
    	taggedDrafts[i].update();
    }

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.