# remove()

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

`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.

Status: free · recursive on a folder · no recycle bin

## Parameters {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `target` | string | required | The file or folder to delete. The workspace root is refused. |

```javascript
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");
```

> **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 {#root}

`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 {#recoverable}

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.

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

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

// Final
await pc.files.remove(path);
```

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| path_not_found | 404 | Nothing at that path. Deleting twice raises this the second time. |
| invalid_path | 400 | Absolute, outside the workspace, or the root. |
| local_files_require_node | 400 | The runtime has no filesystem. |
| storage_not_on_this_machine | 409 | Another computer's storage. |

```javascript
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;
  }
}
```

- [move()](/sdk/ref/local-files/move): The reversible way to make something go away.
- [LocalFiles](/sdk/ref/local-files): The workspace, the path rules, and the shape every method returns.

```python
pc.files.remove("Launch plan/draft.md")
# {"ok": True}

# A folder goes with its contents, at every depth
pc.files.remove("Archive/2026")
```

```python
# Reversible: trash() moves it under .trash/<stamp>/
pc.files.trash(path)

# Final
pc.files.remove(path)
```

```python
def remove_if_there(files, path):
    if not (files.root / path).exists():
        return False
    files.remove(path)
    return True
```
