{"record":{"id":"1202c8509d10f638","repo":"laurent22/joplin","slug":"cannot-find-s-1202c8","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-rmnote.ts","lineNumber":29,"sourceCode":"\t}\n\n\tpublic override description() {\n\t\treturn _('Deletes the notes matching <note-pattern>.');\n\t}\n\n\tpublic override options() {\n\t\treturn [\n\t\t\t['-f, --force', _('Deletes the notes without asking for confirmation.')],\n\t\t\t['-p, --permanent', _('Deletes notes permanently, skipping the trash.')],\n\t\t];\n\t}\n\n\tpublic override async action(args: { 'note-pattern': string; options?: { force?: boolean; permanent?: boolean } }) {\n\t\tconst pattern = args['note-pattern'];\n\t\tconst force = args.options && args.options.force === true;\n\n\t\tconst notes: NoteEntity[] = await app().loadItems(ModelType.Note, pattern);\n\t\tif (!notes.length) throw new Error(_('Cannot find \"%s\".', pattern));\n\n\t\tlet ok = true;\n\t\tif (!force && notes.length > 1) {\n\t\t\tok = await this.prompt(_n('%d note matches this pattern. Delete it?', '%d notes match this pattern. Delete them?', notes.length, notes.length), { booleanAnswerDefault: 'n' });\n\t\t}\n\n\t\tconst permanent = (args.options?.permanent === true) || notes.every(n => !!n.deleted_time);\n\t\tif (!force && permanent) {\n\t\t\tconst message = (\n\t\t\t\t_n('%d note will be permanently deleted. Continue?', '%d notes will be permanently deleted. Continue?', notes.length, notes.length)\n\t\t\t);\n\t\t\tok = await this.prompt(message, { booleanAnswerDefault: 'n' });\n\t\t}\n\n\t\tif (!ok) return;\n\n\t\tconst ids = notes.map(n => n.id);\n\t\tconst options: DeleteOptions = {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-rmnote.ts#L11-L47","documentation":"Thrown by `rmnote <note-pattern>` when `app().loadItems(ModelType.Note, pattern)` returns an empty array. The pattern supports exact title, full id, partial id (>=2 chars), and glob (`*`) when the pattern contains `*` (app.ts:101-104, scoped to currentFolder). After the length check, the command prompts for confirmation (skippable with `-f`) and may force permanent deletion with `-p` or when all matched notes already have `deleted_time`.","triggerScenarios":"Typo in the note pattern; note doesn't exist in the current notebook (non-glob lookups are parent-scoped to currentFolder); partial id <2 chars; note already permanently deleted.","commonSituations":"Bulk-delete scripts with stale titles; running rmnote from the wrong notebook; glob patterns that match nothing.","solutions":["Verify candidates with `joplin ls` and copy exact titles or ids","Switch to the right notebook first: `joplin use <notebook>`","Use a glob to broaden: `joplin rmnote 'Meeting*'`","Use `-f` to skip the confirmation prompt once you've confirmed matches exist"],"exampleFix":"// before\njoplin use WrongBook\njoplin rmnote \"Draft\"   // throws: Cannot find \"Draft\".\n\n// after\njoplin use Work\njoplin ls                       # confirm \"Draft\" is listed\njoplin rmnote Draft\n# or by id, or glob:\njoplin rmnote 'Draf*'","handlingStrategy":"validation","validationCode":"import app from './app';\nimport { ModelType } from '@joplin/lib/BaseModel';\n\nasync function resolveNotesForDelete(pattern: string) {\n  const notes = await app().loadItems(ModelType.Note, pattern);\n  if (!notes.length) throw new Error(`Cannot find \"${pattern}\". Verify with \\`ls\\`, use a glob, or switch notebooks.`);\n  return notes;\n}","typeGuard":"const hasDeleteCandidates = (n: any[]): n is { id: string }[] =>\n  Array.isArray(n) && n.length > 0;","tryCatchPattern":null,"preventionTips":["Resolve note ids with `ls` before destructive `rmnote` calls","Use globs (`Pattern*`) for broader matches, and `-f` only after confirming the match set","Remember note lookups (non-glob) are scoped to currentFolder"],"tags":["cli","rmnote","note-lookup","validation","destructive"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}