スクリプト本体
<%*
const editor = app.workspace.activeLeaf.view.editor;
const currentLine = editor.getLine(editor.getCursor().line);
// クリップボードからファイルパスを取得
const pass = await navigator.clipboard.readText();
const pass_replace = pass.replace(/"/g, '');
// ファイル名をパスから抽出(最後のスラッシュ以降を取得)
const fileName = pass_replace.split(/[\\/]/).pop();
// リンク形式に整形
const updatedLine = '[' + fileName + '](<file://' + pass_replace + '>)';
// 現在の行を更新
editor.setLine(editor.getCursor().line, updatedLine);
%>
使い方
Windows11前提です。
ファイルのパスを取得する
リンクを貼りたいファイルを選んで、Ctrl+Shift+Cでパスを取得します。
右クリックからパスをコピーでもOK。

パスのコピーをします。
ファイルのパスが、クリップボードに保存されます。
obsidian上でスクリプトを起動する
ファイル名がリンクとなります。
後はクリックなりCtrl+Enterなりでリンク先に飛べば、ファイルを開くことができます。
コメント