{"record":{"id":"b225616d8e15050e","repo":"laurent22/joplin","slug":"cannot-find-s-b22561","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-cp.ts","lineNumber":24,"sourceCode":"\nclass Command extends BaseCommand {\n\tpublic override usage() {\n\t\treturn 'cp <note> [notebook]';\n\t}\n\n\tpublic override description() {\n\t\treturn _('Duplicates the notes matching <note> to [notebook]. If no notebook is specified the note is duplicated in the current notebook.');\n\t}\n\n\tpublic override async action(args: { note: string; 'notebook'?: string }) {\n\t\tlet folder = null;\n\t\tif (args['notebook']) {\n\t\t\tfolder = await app().loadItem(ModelType.Folder, args['notebook']);\n\t\t} else {\n\t\t\tfolder = app().currentFolder();\n\t\t}\n\n\t\tif (!folder) throw new Error(_('Cannot find \"%s\".', args['notebook']));\n\n\t\tconst notes = await app().loadItems(ModelType.Note, args['note']);\n\t\tif (!notes.length) throw new Error(_('Cannot find \"%s\".', args['note']));\n\n\t\tfor (let i = 0; i < notes.length; i++) {\n\t\t\tconst newNote = await Note.copyToFolder(notes[i].id, folder.id);\n\t\t\tvoid Note.updateGeolocation(newNote.id);\n\t\t}\n\t}\n}\n\nmodule.exports = Command;\n","sourceCodeStart":6,"sourceCodeEnd":37,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-cp.ts#L6-L37","documentation":"The 'cp' command resolves the destination notebook: either the one named by args['notebook'] via loadItem, or the current folder. If the resolved folder is null it throws 'Cannot find' with the notebook pattern. The message is i18n-translated.","triggerScenarios":"Running 'cp <note> <notebook>' where <notebook> does not exist, or omitting <notebook> while no notebook is current (currentFolder() returns null).","commonSituations":"Typo in the notebook name; notebook not synced; notebook deleted; no notebook selected and none specified.","solutions":["List notebooks with 'ln' to verify the exact name.","Select the destination with 'use <notebook>' and omit the argument.","Sync to pull missing notebooks."],"exampleFix":"# before\n#   joplin cp shopping Work   # 'Work' does not exist\n# after\n#   joplin cp shopping Worknotebook","handlingStrategy":"validation","validationCode":"let folder = args['notebook'] ? await app().loadItem(ModelType.Folder, args['notebook']) : app().currentFolder();\nif (!folder) {\n  console.error(`Notebook not found: ${args['notebook']}`);\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await command.action(args);\n} catch (e) {\n  if (/Cannot find/.test(e.message)) console.error(e.message);\n}","preventionTips":["List notebooks with 'ln' to confirm the destination name.","Omit the notebook argument to copy into the current notebook after 'use'.","Sync before copying to a recently created remote notebook."],"tags":["cli","cp-command","notebook","item-lookup","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}