# Trashcan

**URL:** https://discourse.joplinapp.org/t/trashcan/3998
**Category:** Features
**Created:** [20 October 2019 08:33 UTC](https://discourse.joplinapp.org/t/trashcan/3998 "2019-10-20T08:33:11Z")
**Posts on this page:** 1
**Showing post:** 16

<div class="post-metadata">

### Author: ![laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@laurent](https://discourse.joplinapp.org/u/laurent)
#### Post date: [30 October 2020 10:24 UTC](https://discourse.joplinapp.org/t/trashcan/3998/16 "2020-10-30T10:24:39Z")

</div>

To implement the trash system idea you mentioned above a simple plugin like this could do the job too (not tested but it gives the idea):

```javascript
/* joplin-manifest:
{
	"manifest_version": 1,
	"name": "Trash plugin",
	"version": "1.0.0",}
*/

joplin.plugins.register({
	onStart: async function() {
		await joplin.commands.register({
			name: 'trash',
			label: 'Trash',
			iconName: 'fas fa-trash-alt',
			execute: async () => {
				// Get the selected note and exit if none is currently selected
				const selectedNote = await joplin.workspace.selectedNote();
				if (!selectedNote) return;
				
				// Get the trash folder and create it if it doesn't already exist
				let trashFolder = await joplin.data.get('search', { type: 'folder', query: 'trash' });
				
				if (!trashFolder.items.length) {
					trashFolder = await joplin.data.post('folders', { title: 'trash' });
				} else {
					trashFolder = trashFolder.items[0];
				}

				// Move the note to the trash
				await joplin.data.put(['notes', selectedNote.id], { parent_id: trashFolder.id });
			},
		});
	},
});

```

That would create a new command "trash" which you can assign to any keyboard shortcut.

---

_[View the full topic](https://discourse.joplinapp.org/t/trashcan/3998)._
