nextcloud/server · error · Error

You cannot move a file/folder onto itself or into a subfolde

Error message

You cannot move a file/folder onto itself or into a subfolder of itself

What it means

Error "You cannot move a file/folder onto itself or into a subfolder of itself" thrown in nextcloud/server.

Source

Thrown at apps/files/src/actions/moveOrCopyAction.ts:124

	// Do not allow to MOVE a node to the same folder it is already located
	if (method === MoveCopyAction.MOVE && nodes.some((node) => node.dirname === destination.path)) {
		throw new Error(t('files', 'This file/folder is already in that directory'))
	}

	/**
	 * Example:
	 * - node: /foo/bar/file.txt -> path = /foo/bar/file.txt, destination: /foo
	 *   Allow move of /foo does not start with /foo/bar/file.txt so allow
	 * - node: /foo , destination: /foo/bar
	 *   Do not allow as it would copy foo within itself
	 * - node: /foo/bar.txt, destination: /foo
	 *   Allow copy a file to the same directory
	 * - node: "/foo/bar", destination: "/foo/bar 1"
	 *   Allow to move or copy but we need to check with trailing / otherwise it would report false positive
	 */
	if (nodes.some((node) => `${destination.path}/`.startsWith(`${node.path}/`))) {
		throw new Error(t('files', 'You cannot move a file/folder onto itself or into a subfolder of itself'))
	}

	const nameMapping = new Map<string, string>()
	// Check for conflicts if we do not want to overwrite
	if (!overwrite) {
		const otherNodes = (await getContents(destination.path)).contents
		const conflicts = getConflicts(nodes, otherNodes) as unknown as INode[]
		const nodesToRename: INode[] = []
		if (conflicts.length > 0) {
			if (method === MoveCopyAction.MOVE) {
				// Let the user choose what to do with the conflicting files
				const content = otherNodes.filter((n) => conflicts.some((c) => c.basename === n.basename))
				const result = await openConflictPicker(destination.path, conflicts, content, { overwriting: true })
				if (!result) {
					// User cancelled
					return
				}

View on GitHub (pinned to ecdeb153ff)

When it happens

Trigger: Thrown at apps/files/src/actions/moveOrCopyAction.ts:124 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/329a82e69cf4dbe8. Report an issue: GitHub.