# remove()

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

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

Elimina un file, o un dossier e tutto lo sotto di esso. Nada è mantenut, e la radice del l'espazio di lavoro non può essere il target.

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

## Parâmetros {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `target` | string | obrigatório | Il file o il dossier da cancellare. La radice del workspace è renied. |

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

> **Un dossier è removit con tutto il in esso**
>
> Non vi è negoziat in un dosari che non è vazio, e non lista di ce che va. Se si volve sa, lista prima; se lo vore de volta, move a parte in lugar.

## L'espazio di lavoro in se stesso è negat {#root}

`remove("")` levant `invalid_path`. Vaziar l'area de lavoro non è una operazion que questa classe offre — contiene i files de ogni applicazione de quella macchina, non solo i tuoi.

## La versiòn recuperabile {#recoverable}

Preferì un move in un folder ocult ogni qualquuna che il sentiero venisse da un model, da un form, o da nòmòstu cosa che non ti calcute. Costa lo stesso e è reversible.

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

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

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

## Erros {#errors}

| Código | Status | Quando |
| --- | --- | --- |
| path_not_found | 404 | Nada in quel sentiero. Eliminare due volte eleva questo la seconda vez. |
| invalid_path | 400 | Absolute, fuori del luogo de lavoro, o la radice. |
| local_files_require_node | 400 | O ambiente de execução não tem sistema de arquivos. |
| storage_not_on_this_machine | 409 | Un altro computer's stoccage. |

```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()](/pt/sdk/ref/local-files/move): La via reversibile per fare sparire qualcosa.
- [Fichîes Locales](/pt/sdk/ref/local-files): L'espazio di lavoro, le regole del percorso, e la forma ogni metodo retorna.

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