<%*
const fs = require(“fs”);
const path = require(“path”);
const cp = require(“child_process”);
// 当前笔记的真实路径
const currentPath = “D:/Obsidian_Note/XMU_Note/“+tp.file.path(true);
console.log(currentPath)
// 复制到的目标文件夹 —— 修改这个为你的外部路径
const targetDir = “D:/Secretbase/blog/source/_posts”;
const notename = tp.file.title;
// 保证目标目录存在
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir, { recursive: true });
}

// 生成目标路径:保持同名
const targetPath = path.join(targetDir, tp.file.title + “.md”);

// 执行复制
fs.copyFileSync(currentPath, targetPath);
// ======== 运行 bat 文件 ========
const batPath = “D:/Obsidian_Note/XMU_Note/Scripts/deploy.bat”;

// 调用系统执行 bat
try {
cp.exec("${batPath}", (error, stdout, stderr) => {
if (error) {
console.log(“执行 BAT 出错:”, error);
}
});
} catch (e) {
console.log(e);
}
// 在 Obsidian 内提示成功
new Notice(${notename}已移动并部署到 blog, 5000);
%>