Linux only, reliable but uses a workaround
TLDR: This integration allows you to create markdown links in Obsidian to folders amd opens them in your default file manager.
This integration enables you to link an existing folder to your Obsidian note. You can link any kind of folder (inside or outside of vault) in your current note as a Markdown link. When clicking on the link, the folder is opened in the default file explorer. The link is created by drag and drop or selection of a folder in the default system file picker.
Screencast.From.2024-11-27.21-35-20.mp4
It works by creating a helper .folderlink
file that stores the path to the desired folder. The integration leverages Obsidian's ability to open files with the systems default application. Therefore, this playbook registers a new application that lets you drag and drop or select a folder and stores its path in the .folderlink
file. This way you can basically achieve anything you want to, not only linking folders, basically linking everything you want and very reliably to your Obsidian Note. (I made some more for VS Code repositories etc.).
Run the playbook to set up the application:
ansible-playbook main.yml
The playbook performs the following:
- Copies over the
.desktop
file and script to register the new application. - Adds the MIME type for
.folderlink
files. - Updates the desktop and MIME databases to register the changes.
The setup is non-destructive, as it only adds new files and registers the .folderlink
extension.
Install the Templater plugin in Obsidian. This plugin allows you to create templates with customizable actions.
Create a new template file in Obsidian with the following content:
<%*
const userInput = await tp.system.prompt("Enter a Link Name for the Folder Link");
if (userInput) {
// Create the full filename by appending the user input with the extension
const fullFileName = `${userInput}.folderlink`;
// Get the directory of the current note
const currentDir = tp.file.folder(true);
// Define the path to the attachments folder in the current note's directory
const attachmentFolder = `${currentDir}/attachments`;
// Full file path for the new file
const fullFilePath = `${attachmentFolder}/${fullFileName}`;
// Create the new file with a newline as content
await this.app.vault.create(fullFilePath, ".");
// Insert a relative link to the new file in the current note
const relativePath = `attachments/${fullFileName}`;
tR += `[[${relativePath}]]`;
}
%>
We assume that the helper file should be place in the attachments folder of the current note. The template prompts you to enter a name for the link to the folder, and inserts this as relative link to the folder in the current note.
In Obsidian, go to Settings > Templater > Template Hotkeys and set the new Tempalte as new Hotkey. Assign an 'insert' shortcut to the template file for quick access.
- Use the assigned shortcut to create a new
.folderlink
file in theattachments
folder of the current note and links it in the note. - Clicking the link opens the .folderlink file with the default system application, triggering the application registered by this integration.
- The application then asks you to link the folder or if already linked, opens the folder in your default file manager.