Watched folder: $Tags resetting unexpectedly

Hi,

I’m using a watched finder folder as an inbox for a book list.

Workflow:

  1. Create the books entry in a separate org file with key details in the text. E.g.

:Author: Bloggs, Fred
:StartDate: 02/12/2019
:Tags: Fiction;Historical
etc etc.

  1. Link the finder folder (Books) to a tinderbox container /Inbox, using the Imported from Finder prototype. The only addition to the prototype is a checkbox $Converted, set by default to false.

  2. Run an agent on Inbox:

Query (formatted for ease of reading here):

(inside("/INBOX") & !$Converted) &
($Text.contains("
:Authors: (.+)\n
:StartDate: (.+)\n
:ReadDate: (.+)\n
:BookType: (.+)\n
:Status: (.+)\n
:Rating: (.+)\n
:Tags: (.+)\n
:Location: (.+)\n
:Possessed: (.+)$") )

Action:

$Authors=$1; 
[... similarly for  StartDate to Status$2-$6]
$MySet=$7;
[...ditto for the rest of the attributes] 
$Converted=true;
$Tags=$MySet

This works fine, with one exception. What works is that new documents in the finder folder are picked up by the agent, which reads the contents into the right attributes and sets $Converted so that the agent ignores it in future.

What doesn’t work is getting the tags into $Tags. They are written into $MySet and stay there ($MySet=$7), but the conversion to $Tags doesn’t persist. For about 30 seconds or so after the conversation agent runs, $Tags is populated correctly with the content of $MyTags, but then it is wiped clean. $MySet does not lose data in this way.

I only have one agent running (the conversion one) and it has no rules or edicts. /Inbox has no Actions/Rules/Edicts. In fact the files has no Rules or Edicts at all. I can’t see anything in the agent or /Inbox which would do this.

So I just don’t understand why $Tags is being reset this way. The only thing I can think of is that it’s being reset when the Watch finder folder process runs periodically.

What am I doing wrong, please?

Thanks

See here as in “Finder tags are imported into $Tags.”

As long as the notes are being (re-)populated by the watched folder, $Tags is being set to Finders tags - of which I assume there are none - appearing to thus ‘remove’ the tag values set via your agent.

Suggestions:

  • $Tags is just a Set attribute, albeit with some special import/export interactions. Why not make another Set, e.g. $MyTags, and write the agent to that?
  • Move the newly populated notes out of the target container thus removing them from the agent’s scope. I can see that leaving them in situ allowed for a form of merge if the not is re-eidited in Finder. In that case I’d use the simple fix in the bullet above.

This is a good example of why I write the aTbref notes. Not everything can always make it into the manual immediately. Yet some essentially undocumented things are almost unguessable. The less common, the more easily forgotten. I only thought to check my notes after poring or your code and seeing no $Tags related problem. Not, I hasten to add that my notes are exhaustive or (due to the passage of time) sometimes wrong. Corrections/omissions/clarifications always welcomed.

Thanks, Mark!

I hadn’t thought that it was picking up finder tags as well - that explains it nicely.

I can just use $MySet renamed to $MyTag, as you suggest, but that means having to have two approaches to tagging (the real books list has 700+ entries in /Books which I’ve been adding in TBX for the last ten years. It’s only this year’s books which are in /Inbox.

I don’t really want to move the notes out of Inbox because I want to keep that finder folder up to date (it’s indexed with DevonThink 3 – a future task is to export the existing tbx-only notes out to the finder, but I haven’t got round to that yet). If I move them out of /Inbox they’ll just be reimported, causing distress and gnashing of teeth.

Off the top of my head ways around it:

  • use a temporary finder folder and a folder action to archive the org files to the real DT3 folder when they’ve been imported into TBX (somehow…)

  • alias the imported to /Books.

  • something else completely when I’ve given it more than 2 minutes thought…

Thanks again for solving the initial puzzle!

You could make a new attribute, $BookTopics or $BookTags, to hold both old a new tags. The watch folder rule extracts tags to $BookTags as above. For legacy notes, use an agent:

Query: $Prototype=“Book”
Action: $BookTags |= $Tags

Once that agent has done its work once, you can delete it. The only subtle point is the action, where |= means “set $BookTags only if there’s not something already there.” That prevents accidentally overriding something you meant to set.

That’s excellent - thanks Mark!