sist2
sist2 copied to clipboard
Provide a way to delete a tag so that it is removed from all items
As requested, splitting out from https://github.com/simon987/sist2/issues/401
You should be able to do something like this with the User Scripts:
from sist2 import Sist2Index, Sist2Document
import sys
index = Sist2Index(sys.argv[1])
del_tag = "tag-to-delete"
print("Processing docs....")
for doc in index.document_iter():
if "tag" in doc.json_data:
if del_tag in doc.json_data["tag"]:
doc.json_data["tag"].remove(del_tag)
print("Removed tag from: %s" % doc.json_data["name"])
print("Syncing the tag table....")
index.sync_tag_table()
print("Committing changes....")
index.commit()