# delete-path

Learn how to delete files or directories.

This action deletes a file or directory. If the path does not exist, the action completes silently without error.

## Example

The following template cleans up a temporary directory after setup:

**template.json5**

```json5
{
  "$schema": "https://schema.croct.com/json/v1/template.json",
  "title": "Cleanup",
  "description": "Removes the temporary setup directory.",
  "actions": [
    {
      "name": "delete-path",
      "path": "temp",
      "recursive": true
    },
    {
      "name": "print",
      "semantics": "success",
      "message": "Cleanup complete."
    }
  ]
}
```

To apply this template, run:

```sh
croct use template.json5
```

## Properties

These are the supported properties:

- `name`: `string`

  The action identifier. Always `delete-path` for this action.

- `path`: `string`

  The path to the file or directory to delete.

- `recursive`: `boolean` (optional) (default: false)

  Whether to recursively delete the contents of a directory.

  Required for non-empty directories.

## Explore

- [Create directory](/reference/cli/templates/actions/create-directory): Learn how to create a directory.
- [Move path](/reference/cli/templates/actions/move-path): Learn how to move a file instead of deleting.
- [Locate path](/reference/cli/templates/actions/locate-path): Learn how to find the path to delete.
- [Write file](/reference/cli/templates/actions/write-file): Learn how to write a replacement file.
