Drafts Action Directory

Replace tag…

Posted by @nahumck, Last update 5 months ago

Takes a specified tag and replaces it with a new one.

Install

Steps

  • script

    // replace tags
    
    var p = Prompt.create();
    p.title = "Enter Tags";
    p.message = "Enter the tag you want to replace and the tag you will replace it with."
    p.addTextField("oldTag","Old Tag","")
    p.addTextField("newTag","New Tag","");
    p.addButton("Go");
    var con = p.show();
    
    var oldTag = p.fieldValues["oldTag"];
    var newTag = p.fieldValues["newTag"];
    
    if (con) {
      var items = Draft.query("", "all", [oldTag])
      for (var item of items) {
        item.removeTag(oldTag);
        item.addTag(newTag);
        item.update();  
      }
    }
    else {
      context.cancel
    }

Options

  • After Success Nothing
    Notification Info
    Log Level Error

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.