{"record":{"id":"f035233ce238bef9","repo":"laurent22/joplin","slug":"cannot-find-s-f03523","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-ren.ts","lineNumber":23,"sourceCode":"import Folder from '@joplin/lib/models/Folder';\nimport Note from '@joplin/lib/models/Note';\n\nclass Command extends BaseCommand {\n\tpublic override usage() {\n\t\treturn 'ren <item> <name>';\n\t}\n\n\tpublic override description() {\n\t\treturn _('Renames the given <item> (note or notebook) to <name>.');\n\t}\n\n\tpublic override async action(args: { item: string; name: string }) {\n\t\tconst pattern = args['item'];\n\t\tconst name = args['name'];\n\n\t\tconst item = await app().loadItem('folderOrNote', pattern);\n\t\tthis.encryptionCheck(item);\n\t\tif (!item) throw new Error(_('Cannot find \"%s\".', pattern));\n\n\t\tconst newItem = {\n\t\t\tid: item.id,\n\t\t\ttitle: name,\n\t\t\ttype_: item.type_,\n\t\t};\n\n\t\tif (item.type_ === BaseModel.TYPE_FOLDER) {\n\t\t\tawait Folder.save(newItem);\n\t\t} else {\n\t\t\tawait Note.save(newItem);\n\t\t}\n\t}\n}\n\nmodule.exports = Command;\n","sourceCodeStart":5,"sourceCodeEnd":40,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-ren.ts#L5-L40","documentation":"Thrown by `ren <item> <name>` when `app().loadItem('folderOrNote', pattern)` returns null. The 'folderOrNote' type (app.ts:86-90) tries folders first, then notes if no folder matched. `encryptionCheck(item)` runs before the null check but is null-safe (base-command.ts:21 guards `if (item && ...)`), so it never throws on null. The throw means neither a folder nor a note matched the pattern.","triggerScenarios":"Typo in the item name; item deleted; partial id <2 chars; renaming an encrypted item (hits the encryptionCheck error instead, with message 'Cannot change encrypted item').","commonSituations":"Rename scripts with stale titles; renaming items that were moved to trash.","solutions":["List candidates with `joplin ls /` (folders) and `joplin ls` (notes) and copy the exact title or id","Use the full or short id (>=2 chars) of the item","If the item is encrypted, decrypt it first — otherwise you'll hit 'Cannot change encrypted item'"],"exampleFix":"// before\njoplin ren \"Shoping\" \"Shopping\"   // typo in source -> throws\n\n// after\njoplin ls\n# confirm exact title \"Shopping List\"\njoplin ren \"Shopping List\" \"Groceries\"\n# or by id:\njoplin ren <id> Groceries","handlingStrategy":"validation","validationCode":"import app from './app';\n\nasync function resolveRenameTarget(pattern: string) {\n  const item = await app().loadItem('folderOrNote', pattern);\n  if (!item) throw new Error(`Cannot find \"${pattern}\". Verify with \\`ls\\` / \\`ls /\\`.`);\n  if ((item as any).encryption_applied) throw new Error('Cannot rename an encrypted item; decrypt it first.');\n  return item;\n}","typeGuard":"type FolderOrNote = { id: string; title: string; type_: number };\nconst isFolderOrNote = (x: any): x is FolderOrNote =>\n  !!x && typeof x.id === 'string' && typeof x.title === 'string';","tryCatchPattern":null,"preventionTips":["Use ids rather than titles when renaming in scripts","Decrypt encrypted items before attempting renames","Verify candidate with `ls` (notes) or `ls /` (notebooks) first"],"tags":["cli","ren","lookup","validation"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}