sist2 icon indicating copy to clipboard operation
sist2 copied to clipboard

Provide a way to delete a tag so that it is removed from all items

Open rickcecil opened this issue 2 years ago • 1 comments

As requested, splitting out from https://github.com/simon987/sist2/issues/401

rickcecil avatar Aug 18 '23 03:08 rickcecil

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()

dpieski avatar Dec 06 '23 17:12 dpieski