Launch the selected file in Obsidian

Hi,
I have a link to a file - obsidian://open?vault=Disk-X&file=test
Button launch works well
How to script part - obsidian://open?vault= active file with full path in Directory Opus.
Thank you very much for the advice or guidance
Jirka

{filepath$} will give you the filepath of the selected file.

I suspect you'll want to URL encode it in this situation, which {filepath$|urlencode} will get you (provided you're using 12.24 or above).

obsidian://open?vault={filepath$|urlencode}

See Codes for passing filenames for more detail.

I tried to remove the "urlencode", it will open, but then the introductory Obsidian window and an error message as in the video.
It is a program on a PC, not on the Internet.
It gives these addresses to access as urls, so far it works everywhere.

If you can work out the command line that needs to be generated, we can tell you how to generate it.

I couldn't advise on the correct command line since I don't know anything about Obsidian.

Try ignoring the selected file and {filepath$} stuff and just make a button which launches a hardcoded file path in Obsidian. If you can get that to work, it should be easy to then modify it to insert the selected file path instead of a hardcoded path.

I'll try again, but as in the video.
If I do the + obsidian: // open? Vault = Disk-X & file = test button, that's OK.
If I use the above code with the active file in Directory Opus, it will open as a double-click. Plus with an error message.

What does "Disk-X" mean?

Is the file's name literally "test"? That's just a name, not a full path.

There are some big differences between what you're trying and what you've asked for:

obsidian://open?vault=Disk-X&file=test

vs

obsidian://open?vault= +"active file with full path"

1 Like

You have a sharp eye ;-), now I saw that there is no disk O, only the name of the disk "Disk-X" and the first slash is replaced by &.
Now I'm going to look at the MessageBox in Directory Opus to see the contents of {filepath$}.
I'm getting acquainted with the environment of Opus.

1 Like

So far, I've solved it easily, that's enough for now.
Before I get acquainted with the Directory Opus environment.
I don't know yet when it's better to use Jscript, when to use DO tools.
Now I was looking to open the file using the button from the DO in Obsidian.

Copied beginning of link from Obsidian and from DO.
O:\Disk-X\06_Video_tvorba . . . .
//obsidian://open?vault=Disk-X&file=06_Video_tvorba . . . .

I converted and started
clipboard COPYNAMES={filepath$} REGEXP ..........(.+) \1
obsidian://open?vault=Disk-X&file={clip}

1 Like

obsidian://open?vault=Disk-X&file={file$} should give you the same result without needing to change your clipboard.

If the value=Disk-X part always wants the parent folder name, and there might be more than one vault/folder, then you can improve things a bit more:

obsidian://open?vault={filepath$|..|nopath|noterm}&file={file$}
1 Like

Thank you Leo, better solution ;-). There is still something to learn.
I have to explore the second option.
I have * .MD files on another SSD, for Obsidian only.
No more files to make it run faster.
I originally tried it together with other data, but at approx. 200,000 different files it was slower. And that's just part of the data.

I also have these files on disk in folders
O: \ Disk-X. . . . same folder layout (only *.md files for Obsidian)
X: . . . . same folder arrangement (with other files, backup / copy)
It would be nice if it always opened a file on disk O:\Disk-X
Thank you once again

The drive letter isn't being passed at all with the current commands.

Only the parent folder's name (not full path) and the file's name are being passed.

I'm not sure I understand what you want to do, if you need something else. Could you give some examples?

It's alright this way.
Only with DO options did it occur to me to always open a live / current file on disk O:/ (attachment).
On disk O:/ i only have *.md data for Obsidian, notes.
On disk X: there are all files, pictures, photos, etc., including backed up notes in *.md.
That is, if the active * .md file on disk O:/ is always opened by pressing the button.

I'm sorry, English is not much, so I help myself with a translator ;-).
So open the file on disk O:/ even if it is run from disk X:/ or from disk O:/. The path is always the same except for the beginning

Can you give an example full file path, and the command line you want it to generate?

1 Like

Leo, it's going as it should. Thank you