Unique search terms in order to find memos across documents

Not sure my title is a good one, so feel free to propose a better one!

I have assigned random unicode characters that mean things in notes that are in my databases. (I don’t think it matters, but for interest I’m specifically talking about Δ and )

I had foolishly never actually checked that DT could search on those characters, and just assumed that when I needed to find notes that referenced these characters, DT’s search would magically find them for me. It turns out, this isn’t the case. I don’t know how the magic of search works, but am assuming special characters aren’t supported (and I went to all the effort of avoid emojis thinking I was being clever :joy:)

I assume I am not the only one who might add “keys” to sentences or comments in notes this way, so my question is: how do you do it? Do you use a random string of letters that specifically mean something to you that is unlikely to occur naturally in your files? Or is there another solution I’ve not considered?

The search index of DEVONthink includes only words/numbers (meaning alphanumeric characters) but not white spaces or separators. But of course there’s an exception to the rule as usual :wink:, the characters $€£¥%§ are indexed and therefore one of them might be useful for you.

1 Like

Hashtags? For example, #delta or #next??


JJW

I’m not the OP. But unicode “operators” are indeed much more useful than hashtags for denoting logical relationship. A unicode symbol is more compact, and does not interrupt text as you read through.

If you always use markdown for notes, one workaround is to change all instances of Δ to Δ<span style="display: none">xxxdelta</span>. xxxdelta, or another unique search term of your choice, does not appear in the rendered view of markdown notes.

Drawback of this workaround is significantly less readability in the editing view. If that is an issue, and you don’t do the search quite often, you can apply the <span> tags only when needed, and delete them afterwards.

I think I’d rather stick with a character if I can as it looks much neater in the docs when I’m reading.

I don’t think there’s ever a reason that this symbol would appear genuinely in any of my notes: ¥ (in fact I had to google it to find out what it was!). Does anyone foresee a problem with me using it? (E.g. is it used for anything other than denoting currency that would make it problematic to use as a search term?)

It would be cool to update the “previous” symbol I was using to a new one, once I’ve determined what that is, but I’m not sure how I would do this given that DT can’t search on the symbols I was using previously?

It’s possible to run a script (or smart rule that includes a script), which does not use the DT search index, for this purpose. Check out Scripts > Edit > Replace Text in Documents.

1 Like

If we’re talking about Markdown documents, a script should do the trick. Something like (JavaScript)

(() => {
  const previousChar = 'Δ'; //character to replace
  const replacement = '¥'; // replacement for previousChar
  const app = Application("DEVONthink 3");
  app.databases().forEach(db => { // loop over all databases
    const MDrecords = db.search(`type: "markdown"`); // find all MD documents in database
    MDrecords.filter(record => record.plainText().includes(previousChar)).forEach(record => {
    /*
     * For all MD records containing `previousChar`, replace that char with `replacement`
    */
      record.plainText = record.plainText().replaceAll(previousChar, replacement);
    })
  })
})()

I didn’t test that, though.

Not particularly inventive … I use characters that are easy to type, that I can remember well, but that still produce (almost) no conflicts. These strings all mean something different.

xxa
xxb
xxu
xxs

As long as it makes sense to you and can be effectively used, it’s inventive enough :slight_smile:

1 Like

:joy: Yes, it’s actually good enough for me. “a” or “b” is the first letter of something that I can remember well. And “xx” is just a kind of prefix to make the string unique.

1 Like

Or if you have the files indexed and you are familiar with using the terminal on your Mac, you could use this short shell script:

#!/bin/zsh

for filename in Δ*; do
   [ -f $filename ] || continue 
   mv -v $filename ${filename:s/Δ/¥/}
done

Move to the directory with the files then invoke it.

Here’s what it does:

  1. Iterates through the directory in which you have invoked it;
  2. Looks for files beginning with Δ then;
  3. Tests to see that it is not a folder (the [ -f $filename] bit) and;
  4. Substitutes Δ with ¥ if (2) & (3) are true.

The -v is the verbose flag which tells mv to print an action it has taken.

This assumes you only have a single Δ in the filename (ie you don’t use the same unicode in the filename proper itself or it will also get replaced. The script can be modified if that is the case).

I have used a system for some time, that works for me. All my notes, including ones I put in ‘finder comments’ have an eight letter and date prefix. These do tend to be in headings, titles but a lot are just in ‘finder comments’, as I said.

I have showed it to BLUEFROG regarding my Markdown notes. It is really quite a simple system. The sequences are not going to appear in other searches because of the length and yet easy to remember and are. and example is “trnq nphy 2024-02-28 blah di blah” The text expansion leaves the cursor after the date and I type in details I need. I have more complicated versions on Keyboard Maestro.

The first four letters have just two kinds and there are 9 variations of the second set then the date. I use a text expansion on Keyboard Maestro to do them, it wouldn’t work well if you had to manually type them in. Any text expansion tool would do, I think you might be able to do it with a smart rule, or something like it.

Unless you’re referring to indexed files here, this approach would require messing with the internals of a DT database. Which is generally not recommended.

A better approach would be a script that modifies the filenames and is run from within DT.

1 Like

Yup. Hence the post was prefaced with “if you have files indexed…”.

Agree on not touching the internal database. Who knows, maybe some generated internal file does use Unicode symbols…

Thank you for your help with this everyone. I’ve come up with a unique code I could use. I’ve not implemented it yet though, because this issue has forced me to ponder why I write these notes and how I actually want the information surfacing in future :roll_eyes: The curse of spending too much time thinking about note-taking!

3 Likes