LocalFiles

move()

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.

freenever overwritesfiles and folders
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

fromstringrequired

What to move. A file or a folder.

tostringrequired

Where 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

A move into a dotted folder is a deletion you can undo

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

CodeStatusWhen
path_not_found404Nothing at from.
path_exists409to is taken.
invalid_path400Absolute, outside the workspace, the root, or a folder into itself.
local_files_require_node400The runtime has no filesystem.
storage_not_on_this_machine409Another computer's storage.