# move()

Canonical URL: https://developers.iagenify.com/sdk/ref/local-files/move/
Language: en

`files.move(from, to) → Promise<Item>`

Moves or renames a file or a folder. It refuses to overwrite, which is what makes it safe to call on a path you have not checked.

Status: free · never overwrites · files and folders

## Parameters {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `from` | string | required | What to move. A file or a folder. |
| `to` | string | required | Where it goes. Its parent folders are created. |

```javascript
// Rename
await pc.files.move("notes.md", "Launch plan/notes.md");

// Move a whole folder
await pc.files.move("Launch plan", "Archive/2026/Launch plan");
// { name: "Launch plan", path: "Archive/2026/Launch plan", type: "folder", … }
```

## It refuses rather than replace {#no-overwrite}

A destination that is already taken raises `path_exists`. Nothing is moved, nothing is lost, and the decision of what to do about the collision stays with you.

```javascript
import { IaGenifyError } from "iagenify";

async function moveAside(files, from, to) {
  try {
    return await files.move(from, to);
  } catch (err) {
    if (err instanceof IaGenifyError && err.code === "path_exists") {
      const stamp = new Date().toISOString().slice(0, 10);
      return files.move(from, to.replace(/(\.[^.]+)?$/, ` (${stamp})$1`));
    }
    throw err;
  }
}
```

## A folder cannot go inside itself {#into-itself}

`move("Work", "Work/old")` is refused with `invalid_path`, before anything is touched. Left to the filesystem that operation either fails halfway or loops.

## This is how a recycle bin is built {#trash}

> **A move into a dotted folder is a deletion you can undo**
>
> Hidden entries stay out of list(), so moving something under .trash// removes it from view while keeping every byte. That is exactly what the agent's delete tool does, and you can do the same.

```javascript
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
await pc.files.move("Launch plan/draft.md", `.trash/${stamp}/Launch plan/draft.md`);
```

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| path_not_found | 404 | Nothing at `from`. |
| path_exists | 409 | `to` is taken. |
| invalid_path | 400 | Absolute, outside the workspace, the root, or a folder into itself. |
| local_files_require_node | 400 | The runtime has no filesystem. |
| storage_not_on_this_machine | 409 | Another computer's storage. |

- [remove()](/sdk/ref/local-files/remove): Delete for real, when a move aside is not what you want.
- [LocalFiles](/sdk/ref/local-files): The workspace, the path rules, and the shape every method returns.

```python
# Rename
pc.files.move("notes.md", "Launch plan/notes.md")

# Move a whole folder
pc.files.move("Launch plan", "Archive/2026/Launch plan")
# {"path": "Archive/2026/Launch plan"}
```

```python
import re
from datetime import date

def move_aside(files, source, destination):
    if (files.root / destination).exists():
        stamp = date.today().isoformat()
        destination = re.sub(r"(\.[^.]+)?$", lambda m: f" ({stamp}){m.group(1) or ''}", destination, count=1)
    return files.move(source, destination)
```

```python
from datetime import datetime, timezone

stamp = datetime.now(timezone.utc).isoformat().replace(":", "-").replace(".", "-")
pc.files.move("Launch plan/draft.md", f".trash/{stamp}/Launch plan/draft.md")
```
