Action

Replace tag…

Posted by @nahumck, Last update over 6 years ago

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

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
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.