{"record":{"id":"329a82e69cf4dbe8","repo":"nextcloud/server","slug":"you-cannot-move-a-file-folder-onto-itself-or-into","errorCode":null,"errorMessage":"You cannot move a file/folder onto itself or into a subfolder of itself","messagePattern":"You cannot move a file/folder onto itself or into a subfolder of itself","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/files/src/actions/moveOrCopyAction.ts","lineNumber":124,"sourceCode":"\n\t// Do not allow to MOVE a node to the same folder it is already located\n\tif (method === MoveCopyAction.MOVE && nodes.some((node) => node.dirname === destination.path)) {\n\t\tthrow new Error(t('files', 'This file/folder is already in that directory'))\n\t}\n\n\t/**\n\t * Example:\n\t * - node: /foo/bar/file.txt -> path = /foo/bar/file.txt, destination: /foo\n\t *   Allow move of /foo does not start with /foo/bar/file.txt so allow\n\t * - node: /foo , destination: /foo/bar\n\t *   Do not allow as it would copy foo within itself\n\t * - node: /foo/bar.txt, destination: /foo\n\t *   Allow copy a file to the same directory\n\t * - node: \"/foo/bar\", destination: \"/foo/bar 1\"\n\t *   Allow to move or copy but we need to check with trailing / otherwise it would report false positive\n\t */\n\tif (nodes.some((node) => `${destination.path}/`.startsWith(`${node.path}/`))) {\n\t\tthrow new Error(t('files', 'You cannot move a file/folder onto itself or into a subfolder of itself'))\n\t}\n\n\tconst nameMapping = new Map<string, string>()\n\t// Check for conflicts if we do not want to overwrite\n\tif (!overwrite) {\n\t\tconst otherNodes = (await getContents(destination.path)).contents\n\t\tconst conflicts = getConflicts(nodes, otherNodes) as unknown as INode[]\n\t\tconst nodesToRename: INode[] = []\n\t\tif (conflicts.length > 0) {\n\t\t\tif (method === MoveCopyAction.MOVE) {\n\t\t\t\t// Let the user choose what to do with the conflicting files\n\t\t\t\tconst content = otherNodes.filter((n) => conflicts.some((c) => c.basename === n.basename))\n\t\t\t\tconst result = await openConflictPicker(destination.path, conflicts, content, { overwriting: true })\n\t\t\t\tif (!result) {\n\t\t\t\t\t// User cancelled\n\t\t\t\t\treturn\n\t\t\t\t}\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/files/src/actions/moveOrCopyAction.ts#L106-L142","documentation":"Error \"You cannot move a file/folder onto itself or into a subfolder of itself\" thrown in nextcloud/server.","triggerScenarios":"Thrown at apps/files/src/actions/moveOrCopyAction.ts:124 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}