How to find notes without aliases?

This is surely achievable, but I don’t know how. I am wondering what would be the query in an agent in order to find all notes in a TB file which have no aliases, wherever they are placed in the TB file.

Notes don’t store a list of their aliases so you can’t interrogate it correctly. However, we can get the inverse, a list of all notes with an alias. An agent with the simple query $IsAlias will do this. as an agent de-dupes there will only be one listing per note regardless of the number of aliases a note has. That works in an agent but the agent can’t list the non-matching items because if you test $IsAlias==false a note with an alias will de-dupe to list the original giving a false reading. If you want to find only ‘manual’ aliases make sure you delete all other agents before testing

One approach would be to run the original query and use the agent action a user Boolean $HasAlias to true. Then you can run an an agent and test for $HasAlias==false. note that you’ve need to reset this attribute globally if the number of aliases changes.

Or, use the top method to get all the aliases notes and make a set of their original’s $Path values (thus allowing for duped $Name values). Make another set of all $Path values and then subtract the former from the latter (see here). got to head out - so last is not tested.

1 Like

Thanks for your explanation. I’am afraid it is too complex for me at this stage. I’ll explain the use case, in case you can propose an easier solution than the one I’ve thought of.
I make aliases of all annotations imported from a watched DT folder, and move them elsewhere. Originals are left in the top folder, so that they will not be imported anew by TB. What I need is a way to easily see which notes have no aliases in the top foler, or at least which notes are new.

Back now, and testing more, the $IsAlias query isn’t that reliable on it’s own as it can detect aliases in the agent itself. But, the following does work for me. Note that I’m using $Name with the assumption that all notes/agent $Name are unique.

In an agent I have the $AgentQuery:

$IsAlias & $Name(parent)!=$Name(agent)

This ensures we only detect aliases that aren’t in this agent. If you want to exclude aliases in all agents - i.e. filter only manually created aliases and ignore agents then use this query:

`IsAlias & $AgentQuery(parent)==""

Next the agent’s $Rule:

$MySet=collect(children,$Name);
$MySet2=collect_if(all,$AgentQuery=="",$Name);
$Text = ($MySet2-$MySet).format("\n");

Firstly, $MySet collects a list of the $Name of all the aliases found. Second, $MySet2 collects a list of every note in the document except agents. Lastly, subtracting $MySet from $MySet2 gives us a list of $Name of notes with no aliases and which we then format as one value per line and set as the $Text of the agent.

I’ve only tested this (in v7.3.0) on a small doc with c.10 items. I’m not sure how/if this scales to your document. I’d suggest you make a copy of your document and then try out the above .note, $MySet2 is a Set-type User attribute. If you don’t use unique note $Name then substitute $Path for $Name everywhere you see it above.

Separately, I understand your use case but ultimately I think you’re heading up a blind alley. The DT watched group is intended to watch one (and only one) group and has a design intent that group be small to avoid excessive inter-app load. I presume ‘small’ is <10 items so you might as well track this by hand.

I should note that the last paragraph is written as at v7.3.0. the DT watched group feature will evolve and may support a richer feature set along the lines of your need, but not currently. Thus I’d use a different approach for now as you’e just making hard work for yourself. I’d go with the suggestion made in another thread of making a note per DT item of interest and setting them to auto-fetch. If you use a prototype for all these notes then you could turn $AutoFetch on/off for all the notes from the prototype.

Thanks for your detailed reply. That would lead to an ideal solution, but I can’t get it to work. Therefore, I’ll test a simpler approach: to make a prototype that will color the originals after I’ve manually made aliases.

1 Like