Why is a path necessary when specifying a note?

Loving what you are doing with Actions for Obsidian. I’m hoping it will solve some problems that AdvancedURI isn’t, and, at the same time, make shortcuts easier and more readable. I am running into one issue: it appears I have to specify the path to the note. That seems strange, as I don’t want to encode my vault layout unnecessarily in other tools. Kinda makes it hard to refactor on the fly. Apologies if I am just missing something, but if the path is required, I’d sure like to know why and request a path-less note capability. Thanks!

1 Like

Welcome aboard, @Brian_Batchelder! :vulcan_salute:t3:

I’ve built it that way because when you have various notes with the same name (e.g., I have a “Roadmap” note for each of my bigger projects) you want to specify the full path to get the correct one. Making paths explicit prevents accidental foot guns since many of AfO’s actions can be destructive.

What other behavior would you expect here? I’m open to suggestions and ideas :wink:

Hmm. I’m all for not accidentally shooting myself in the foot, but I do like the option. Maybe with a heavy warning. I have some thoughts:

  • Explicit path means use that specific note. Just passing a note name means find that note and use it. If multiple notes match the name, fail with “multiple matching notes” error (just like “no matching note”).
  • Same thing, except require setting a flag to mean “search for note in vault”. Keep current definition of path / note name the same when flag is not set.

Check for note could also be extended to return a flag that indicates “multiple notes match name”. This could also grow into some regex-matching in the future.

PS - Thanks for this incredible tool!

I use Data Jar for these global settings in a dictionary for “obsidian”, which includes keys for vault name and various paths that I use. Then I can use get a specific value by key when needed. I can either embed it directly in an Actions for Obsidian action, or explicitly use Get Value from Data Jar and Set Variable, if I want to use it several times. If I ever change Obsidian, I only have to update it in Data Jar, and all my shortcuts automatically use the new setting. This seems to work well.

Thanks for the explanation! I see your point but also, you’re the first customer to ask for this behaviour. :wink:

Currently, AfO (or more specifically, its companion plugin Actions URI) uses the “open file X” functions of the Obsidian API, which expect an absolute file path starting at the root of the vault. The quite user-friendly behavior in the Obsidian application of finding a file by its name isn’t exposed in the API, so I’d have to recreate it. While it’s likely not overly complicated, it is a potentially breaking change, and I need to think about the ramifications before implementing it.

I was just trying to figure out how to accomplish the same thing @Brian_Batchelder is referencing: pull up a note just by name. I was playing around with various action and conditional combinations to do this, but I’m not coming up with anything simple. For example, with the basic Obsidian URI, I can run something like this: obsidian://open?file=Philosophy and it will pull up the note anywhere in the vault (regardless of path). Of course, if there are multiple notes of the same name, it’s a problem.

Anway, I was thinking that there could be an action to always retrieve the note that is the first match in the list (I’m feeling lucky kind of thing) or maybe the one sorted highest in the path tree. I realize any defaults are problematic/trade-offs.

Happy to help test or bounce around ideas. Thanks for a wonderful package of actions!

Hmm, maybe a new “Find Note By Name” action would suffice? It’d return a note object including file path which could be used as input by other actions. What do you think, @Darren, @Brian_Batchelder, @doug78645?

PS: Welcome to the forum, Darren!

That could work! This way, we could build a simple shortcut where we pull back a note by name that we know is unique, and then we could always build more complex ones. For instance, what I’m doing now is using an Omnisearch on the name and then prompting to select the note to open. If your “Find Note by Name” returned a single note object, that would certainly for that simple view.

By the way, I tested the behavior of the vanilla Obsidian URI on opening a note for multiple notes of the same name. It looks like it basically walks the path tree, meaning if a note exists in root (“/”), then that will open first; and then any note in paths sorted by natural order.

Quick update: I’m currently working on it!

I’ve added a toggle to Get Note which lets you fetch the note by its title. Works well and will be in part of the upcoming v1.5!

CleanShot 2024-02-07 at 18.18.50