Any way to create "Show in system explorer" function?

in Obsidian, when you right click a ralative path , you have option to “Show in system explorer”

i used “attachedment plugin” to generate _canonical_uri: tiddlyer with relative patch, is there any way in TW to mirror this Obsidian function?

image

this is what i got from Grok3, feel like so close to the solution, but still not working for me.

Key Points

  • To replicate Obsidian’s “Show in System Explorer” function with relative paths in TiddlyWiki Desktop (TiddlyDesktop), create a custom JavaScript tiddler to handle folder opening and add a button to trigger it.

  • This works by resolving the relative path to an absolute folder path and using system commands to open it in the explorer.

  • It requires TiddlyDesktop, not browser-based TiddlyWiki, due to security restrictions.

1. Create the JavaScript Tiddler

  • Name the tiddler $:/scripts/openFolder and set its type to application/javascript.

  • Add the following code to handle opening the folder:

(function() {

var openFolder = function(event) {
    var relativePath = event.param;
    var wikiUrl = window.location.href;
    var wikiPath = require('url').fileURLToPath(wikiUrl);
    var wikiDir = require('path').dirname(wikiPath);
    var absolutePath = require('path').join(wikiDir, relativePath);
    var folderPath;
    if (relativePath.endsWith('/')) {
        folderPath = absolutePath;
    } else {
        folderPath = require('path').dirname(absolutePath);
    }
    var nw = require('nw.gui');
    nw.Shell.openItem(folderPath);
};

$tw.hooks.addHook("th-message", function(event) {
    if(event.message === "openFolder") {
        openFolder(event);
    }
});

})();
  • This code listens for an openFolder message, resolves the relative path to an absolute folder path, and opens it using NW.js’s Shell.openItem.

2. Add the Button in Your Tiddler

  • In the tiddler where you want to open the folder (e.g., MyFileLink), add a field file-path with the relative path, like files/example.pdf.

  • Add a button to trigger the folder opening:

title: MyFileLink
file-path: files/example.pdf

This is a link to a file: {{!!file-path}}

<$button>Open Folder
  <$action-sendmessage $message="openFolder" $param={{!!file-path}}/>
</$button>

When clicked, this button sends the openFolder message with the relative path, and the JavaScript tiddler handles opening the folder in your system explorer.

@jeremyruston … Will AI created code like this work in TiddlyDesktop? I know it does not work with the browser, but I do not know if TD allows commands like var wikiDir = require('path').dirname(wikiPath);

am not sure as well. hope some one have a solution for this. it is a very nice feature in Obsidian, hope can replicate here in Tiddlywiki.