obsidian-auto-note-mover
obsidian-auto-note-mover copied to clipboard
Feature Request: move notes ONLY if two or more tags match
move notes ONLY if two or more tags match
I have this structure in my vault
Full of Crap Development Articles
- Psychology
- Legal
- Business
- Children
Essays
- Business
- Legal
Then Id like to move notes to Articles/Legal ONLY if they contain BOTH tags #article and #legal
in this way I can have articles I clipped from the internet separated from essays im writing
Thanks in advance.
Do you mean that the Articles folder and the Legal folder are nested folders, but the Articles tag and the Legal tag are separate tags that are not nested?
This is difficult to do because the plugin engine would have to be rebuilt.
Exactly, with regex, it is possible to match this scenario.
https://regex101.com/r/cao82g/1
But if one prefers to use a js function to match two tags, what about something like:
var input = `---
author: Karen the Trollmaster
tags: noise, legal, irrelevant, article
keywords: pff, nobody, likes, "a Karen", "not this", article // < don't match this one
---`;
var keywords = ["article", "legal"];
var regexp = new RegExp("\\b(" + keywords.join("|") + ")\\b", "g");
var matches = input.match(/\btags:.*?(?=\n|$)/)[0].match(regexp);
console.log(matches);
Actually, ANM does not do a full-text search for tags. Obsidian Api returns tags as an array, so it loops through the array of rules and the array of tags to check them, and if they match, it moves the note. To achieve this, it is necessary to build a mechanism to increase the number of loops to check the rules for each additional tag to be searched, and to modify the configuration tabs and so on. Of course, each time the number of loops increases, the processing speed will decrease. Making this change is like creating another plugin, so I can't respond right away. Sorry.
Thank you very much for taking the time to answer!
I don't know about obsidian plugin API, but it already can do multiple tag search.
if you enter in the tag search field the next term it looks for the two tags.
tag:#article tag:#legal
and in regard of the GUI, probably just a comma to separate multiple tags.
Have a nice day!
@alanalvarado I needed the same functionality #52