LocalFiles

remove()

files.remove(target) → Promise<{ ok: true }>

Deletes a file, or a folder and everything under it. Nothing is kept, and the workspace root cannot be the target.

freerecursive on a folderno recycle bin
Using Python?

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

Parameters

targetstringrequired

The file or folder to delete. The workspace root is refused.

await pc.files.remove("Launch plan/draft.md");
// { ok: true }

// A folder goes with its contents, at every depth
await pc.files.remove("Archive/2026");
pc.files.remove("Launch plan/draft.md")
# {"ok": True}

# A folder goes with its contents, at every depth
pc.files.remove("Archive/2026")
A folder is removed with everything in it

There is no refusal on a folder that is not empty, and no listing of what went. If you want to know, list it first; if you want it back, move it aside instead.

The workspace itself is refused

remove("") raises invalid_path. Emptying the workspace is not an operation this class offers — it holds the files of every application on that machine, not only yours.

The recoverable version

Prefer a move into a hidden folder whenever the path came from a model, from a form, or from anything you did not compute yourself. It costs the same and it is reversible.

const stamp = new Date().toISOString().replace(/[:.]/g, "-");

// Reversible
await pc.files.move(path, `.trash/${stamp}/${path}`);

// Final
await pc.files.remove(path);
# Reversible: trash() moves it under .trash/<stamp>/
pc.files.trash(path)

# Final
pc.files.remove(path)

Errors

CodeStatusWhen
path_not_found404Nothing at that path. Deleting twice raises this the second time.
invalid_path400Absolute, outside the workspace, or the root.
local_files_require_node400The runtime has no filesystem.
storage_not_on_this_machine409Another computer's storage.
import { IaGenifyError } from "iagenify";

async function removeIfThere(files, path) {
  try {
    await files.remove(path);
    return true;
  } catch (err) {
    if (err instanceof IaGenifyError && err.code === "path_not_found") return false;
    throw err;
  }
}
def remove_if_there(files, path):
    if not (files.root / path).exists():
        return False
    files.remove(path)
    return True