Bulk remove notes

(Christian) #1

I did a mistake with an agent and created thousand of notes with the same title. How can I now remove all these notes at once?

I tried:

  • to build an agent and then delete them all in the agent view. Does not work.
  • to set a query in the attribute browser, but can only delete notes one by one.
  • to find a solution on this forum without luck.

What’s the fastest and best way to remove identical notes? Thanks!

(Mark Anderson) #2

An agent can’t create notes . Are you sure these aren’t aliases?

(Christian) #3

I canot recall how I made it possible, but they all seem notes. Unfortunately these are not aliases. All notes. Does it mean I have to erase them manually?

(Paul Walters) #4

Create a note at the the root whose name is “Trash”. (Or call it whatever you want, it makes no difference.)

Create an agent whose query is:

$Name.contains("Title of notes I want to delete"); <-- obviously use the correct name here

and whose action is


When the notes have been moved by the action, inspect the contents of “Trash”. When you’re satisfied, delete the “Trash”.

HOWEVER – you will possibly capture something in “Trash” you don’t want to be there, so you’ll need to put it back where it belongs. Actions that change containers run the risk of destroying your work and the structure of your document. With NO possibility of undoing the action. Be very careful and do not use what I recommend unless you are certain you understand the consequences. Test this on a duplicate of your main file and make sure you have multiple backup copies.

(James Fallows) #5

Of course agree on the caution --and the recommendation.

Question: could you build in a protection against this irreversibility, with a sequence like this?

  • Create a new string attribute, like $OldPath
  • Set up an agent to deal with all items, or just the ones you think might be deleted, and have its action be $OldPath=$Path(original). (Which would assign the existing container structure to an attribute – and save it for later reference.) Obviously you would want to run this agent only once, or maybe apply it as a stamp, so it wouldn’t get updated and overwritten if you moved the originals.
  • Then apply the agent that would move the notes to the \Trash container.

As a failsafe, you could send things back to where they started with an undo-style agent, whose action was $Path(original)=$OldPath(original). Right? Or is there a step I am not understanding?

(Paul Walters) #6

I’m sure that would work.

To simplify things, I’d just advocate duplicating the document and working on a copy until satisfied.

(eastgate) #7

There is, literally, no way for an agent action to create a note.

I’m reasonably sure it’s just not possible. So, I’d be interested to see what actually happened here!

(James Fallows) #9

Correction to my earlier post: if you had saved the previous note location with $OldPath=$Path(original), then the way to restore it would be $Container(original)=$OldPath rather than the other formulation I had. (I think.)

Agree on trying this out thoroughly on a copy of the real file to be sure it does what it’s supposed to.

(Paul Walters) #10

I believe you’ll want your agent to always operate on the “original” and not change the agent’s aliases paths. So the safety agent’s action is $OldPath(original)=$Path(original) and the restoration agent’s action is $Container(original)=$OldPath(original).

Otherwise Tinderbox will assume “this” for $OldPath in the action $OldPath=$Path(original) and the restoration agent will send the originals to the wrong place.

(I’m making assertions I haven’t tested, which isn’t a great idea :exploding_head: – although speak-first-research-later-or-never seems consistent with our times :laughing:.)

(Christian) #11

I am pretty sure it came from this experiment: Fetching RSS feeds into Tinderbox one item per feed item
I noticed months after. I have almost 3000 notes with the same title/name all across my file.

(Christian) #12

Thanks a lot @PaulWalters that worked like charm.

(Mark Anderson) #13

That thread is about drag/drop addition of text files. Such an event would create a new note per dropped text file. That’s the source. The duplicated title is due to an error either at source (outside Tinderbox) or in action code you’ve made to rename the newly added notes.