Fichîes Locales

remove()

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.

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.

Parâmetros

targetstringobrigatório

Il file o il dossier da cancellare. La radice del workspace è renied.

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

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

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.

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)

Erros

CódigoStatusQuando
path_not_found404Nada in quel sentiero. Eliminare due volte eleva questo la seconda vez.
invalid_path400Absolute, fuori del luogo de lavoro, o la radice.
local_files_require_node400O ambiente de execução não tem sistema de arquivos.
storage_not_on_this_machine409Un altro computer's stoccage.
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