Parameters
fromstringrequiredWhat to move. A file or a folder.
tostringrequiredWhere it goes. Its parent folders are created.
// 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", … }# 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"}It refuses rather than replace
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.
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;
}
}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)A folder cannot go inside 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
Hidden entries stay out of list(), so moving something under .trash/<timestamp>/ removes it from view while keeping every byte. That is exactly what the agent's delete tool does, and you can do the same.
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
await pc.files.move("Launch plan/draft.md", `.trash/${stamp}/Launch plan/draft.md`);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")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. |