Last active
November 30, 2022 10:34
-
-
Save jdpilgrim/a62b4895a06a27415040ca523518f1c5 to your computer and use it in GitHub Desktop.
Obsidian QuickAdd script to copy a file into a sub folder with the same name. Handly to use with folder note plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function moveFilesWithTag(params) { | |
const { | |
app, | |
quickAddApi: { suggester, yesNoPrompt }, | |
} = params; | |
/* ... */ | |
const { workspace, vault } = this.app; | |
const activeView = workspace.getActiveFile(); | |
if (activeView) { // The active view might not be a markdown view | |
const folder = `${activeView.parent.path}/${activeView.basename}` | |
const folderAbstractFile = vault.getAbstractFileByPath(folder); | |
if(folderAbstractFile) | |
{} | |
else | |
{ | |
await vault.createFolder(folder); | |
} | |
await app.fileManager.renameFile( | |
activeView, | |
`${folder}/${activeView.name}` | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment