# [[How to delete a file from within Obsidian]]
You can use a [[JavaScript]] function to delete files in [[Obsidian]]. This code can be saved as a .js file and used in conjunction with [[Obsidian Templater]].
```javascript
async function deleteThis () {
const file = app.vault.getAbstractFileByPath("✉️inbox/deleteThis1.md");
await app.vault.trash(file, true);
return '<% tp.user.deleteThis() %>';
}
module.exports = deleteThis;
```
Thanks to Robert on [my Patreon](https://patreon.com/nicolevdh) for letting me know about this!