import { Plugin } from "obsidian"; export default class PAUL extends Plugin { async onload() { // Command 추가 this.addCommand({ id: 'FileToFolder', name: 'File to Folder', callback: () => { this.fileToFolder(); }, }); } // Actual functions async fileToFolder() { const activeFile = this.app.workspace.getActiveFile(); if (!activeFile) { new Notice('No file is open.'); return; } const fileBaseName = activeFile.basename; const fileExtension = activeFile.extension; const folderPath = `${activeFile.parent.path}/${fileBaseName}`; try { // Create the folder await this.app.vault.createFolder(folderPath); // Move the file into the folder await this.app.vault.rename(activeFile, `${folderPath}/${fileBaseName}.${fileExtension}`); new Notice('File moved to new folder successfully.'); } catch (error) { console.error("Error in FileToFolder plugin:", error); new Notice('An error occurred.'); } } }