Tinderbox Forum

Code to find notes within a container without any text and/or basic links?

Hi everyone
I am interested in better associating my tinderbox notes with one another. In the past I have relied primarily on containers to organize my notes, however am wanting to better associate my ideas to one another. In this process of reviewing my notes/containers I am interested in finding my “orphan notes” without any lins/associations however am needing help in coding the query.

Example 1: finding text links?
I am interested in finding any note within a container that does NOT contain any text links within the text of the note. How would I do this?
I have 1 container that contains 50 notes. I want to create an agent looking for any note within this container that does NOT contain any Text Links? All Text links (inbound and outband) How do I create this query?

Example 2:finding note (basic) links?
As a follow up question: 2nd part: how would I find notes that do not basic links (links that apply to the entire note instead of text) that I commonly use in map view?

Thanks in advance

#1. So, how might we count text links. How about $TextLinkCount. So for container “Some container”, the agent query would be:

inside("Some container") & $TextLinkCount==0

IOW, a note in that container where the note has no text links but may have basic or web links. We don’t need to use $TextLinkCount(original) as originals and aliases share text links.

Well that’s harder. Inbound text links to text only became possible in v7.5.0+ and inbound links that originate from source $text anchors aren’t measured separately. If you wanted to check all inbound links you can check $InboundLinkCount(original)==0.

#2. Here you use:

inside("Some container") & $PlainLinkCount(original)==0

Thanks Mark. Code for #1 worked but I am slightly confused by the value of “original” in #2 code below:

inside(“Some container”) & $PlainLinkCount(original)==0

2 quick questions about the codes above:

Q: “original”: I assume this is a single note. I would like to catch any “orphan” notes without any basic links within a container. Is there a way to refer to the contents of a container when using the $PlainLinkCount() operator. I guess I am not sure if original refers to the note itself or if the PlainLinkCount operator can “look inside”.

  1. I noticed you used inside() instead of descendedFrom(). Is there a difference. When do you suggest using one or the other. I typically used descendedFrom, which is why I am asking.

Thanks in advance,

Please read up on Designators and on Intrinsic Attributes. By convention, designators aren’t quoted but literal note names are. Thus:


Evaluates the $PlainLinkCount of the original of the current object, whilst:


Evaluates the $PlainLinkCount of a note with the $Name ‘original’.

Well, you didn’t define the degree of ‘contains’. I made the conservative assumption you meant the direct children of the container as opposed to children and their descendants. Use whichever scope you need, but this point shows why it helps to be specific when asking a question. If you’d said “all items descended from the container” then it would be obvious you wish to include descendants.

More: inside() and descendedFrom().

Thanks Mark for the clarification on the multiple points above. Using links in combination with agents is new for me. I will dive deeper in the two areas suggested above. Well said in differentiating the difference between inside and descendedFrom. I now understand the difference relates to depth of scope between the two operators. Very much appreciated.

All the best,

1 Like

Happy to help. :grinning: