{"record":{"id":"93ed997bed137d81","repo":"laurent22/joplin","slug":"cannot-find-s-93ed99","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-mv.ts","lineNumber":24,"sourceCode":"import Note from '@joplin/lib/models/Note';\n\nclass Command extends BaseCommand {\n\tpublic override usage() {\n\t\treturn 'mv <item> [notebook]';\n\t}\n\n\tpublic override description() {\n\t\treturn _('Moves the given <item> to [notebook]');\n\t}\n\n\tpublic override async action(args: { item: string; 'notebook': string }) {\n\t\tconst pattern = args['item'];\n\t\tconst destination = args['notebook'];\n\t\tlet folder = null;\n\n\t\tif (destination !== 'root') {\n\t\t\tfolder = await app().loadItem(ModelType.Folder, destination);\n\t\t\tif (!folder) throw new Error(_('Cannot find \"%s\".', destination));\n\t\t}\n\n\t\tconst destinationDuplicates = await Folder.search({ titlePattern: destination, limit: 2 });\n\t\tif (destinationDuplicates.length > 1) {\n\t\t\tthrow new Error(_('Ambiguous notebook \"%s\". Please use short notebook id instead - press \"ti\" to see the short notebook id', destination));\n\t\t}\n\n\t\tconst itemFolder = await app().loadItem(ModelType.Folder, pattern);\n\t\tif (itemFolder) {\n\t\t\tconst sourceDuplicates = await Folder.search({ titlePattern: pattern, limit: 2 });\n\t\t\tif (sourceDuplicates.length > 1) {\n\t\t\t\tthrow new Error(_('Ambiguous notebook \"%s\". Please use notebook id instead - press \"ti\" to see the short notebook id or use $b for current selected notebook', pattern));\n\t\t\t}\n\t\t\tif (destination === 'root') {\n\t\t\t\tawait Folder.moveToFolder(itemFolder.id, '');\n\t\t\t} else {\n\t\t\t\tawait Folder.moveToFolder(itemFolder.id, folder.id);\n\t\t\t}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-mv.ts#L6-L42","documentation":"Thrown by `mv <item> <notebook>` when the destination is not the literal string 'root' and `app().loadItem(ModelType.Folder, destination)` returns null. 'root' is special-cased just above and bypasses the lookup (it moves the item to the top level). Folder lookup is global by exact title, full id, or partial id >=2 chars.","triggerScenarios":"Typo in the destination notebook name; destination deleted/renamed; partial id <2 chars; forgetting the literal `root` keyword when moving to the top level.","commonSituations":"Restructuring notebooks and misspelling the target; using a note id where a notebook id is required.","solutions":["List notebooks with `joplin ls /` and use the exact title or id","Use the literal `root` as the destination to move to the top level","Use the short notebook id (toggle with `ti`)"],"exampleFix":"// before\njoplin mv ProjectA Projcts   // typo, throws\n\n// after\njoplin ls /\n# title is \"Projects\"\njoplin mv ProjectA Projects\n# or move to top level:\njoplin mv ProjectA root","handlingStrategy":"validation","validationCode":"import app from './app';\nimport { ModelType } from '@joplin/lib/BaseModel';\n\nasync function resolveMoveDestination(destRef: string) {\n  if (destRef === 'root') return null; // top-level move\n  const folder = await app().loadItem(ModelType.Folder, destRef);\n  if (!folder) throw new Error(`Cannot find destination notebook \"${destRef}\". Verify with \\`ls /\\` or use \\`root\\`.`);\n  return folder;\n}","typeGuard":"const isFolderOrNullRoot = (f: any, ref: string): boolean =>\n  ref === 'root' ? true : (!!f && typeof f.id === 'string');","tryCatchPattern":null,"preventionTips":["Use `root` literally when moving to the top level","Verify destination with `ls /` first","Prefer notebook ids over titles in scripts"],"tags":["cli","mv","notebook-lookup","validation"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}