import Global from '../../_global.mdx';

# spo file remove

Removes the specified file

## Usage

```sh
m365 spo file remove [options]
```

## Alias

```sh
m365 spo page template remove
```

## Options

```md definition-list
`-u, --webUrl <webUrl>`
: URL of the site where the file to remove is located.

`-i, --id [id]`
: The ID of the file to remove. Specify either `id` or `url` but not both.

`--url [url]`
: The server- or site-relative decoded URL of the file to remove. Specify either `id` or `url` but not both.

`--recycle`
: Recycle the file instead of actually deleting it.

`--bypassSharedLock`
: Remove the file even if it is locked for shared use.

`-f, --force`
: Don't prompt for confirming removing the file.
```

<Global />

## Examples

Remove a file by ID.

```sh
m365 spo file remove --webUrl https://contoso.sharepoint.com/sites/project-x --id 0cd891ef-afce-4e55-b836-fce03286cccf
```

Remove a file by site-relative URL.

```sh
m365 spo file remove --webUrl https://contoso.sharepoint.com/sites/project-x --url "/Shared Documents/Test.docx"
```

Remove a file by server-relative URL to the recycle bin.

```sh
m365 spo file remove --webUrl https://contoso.sharepoint.com/sites/project-x --url "/sites/project-x/Shared Documents/Test.docx" --recycle
```

Remove a file that is locked

```sh
m365 spo file remove --webUrl https://contoso.sharepoint.com/sites/project-x --url "/Shared Documents/Test.docx" --bypassSharedLock
```

Remove a page template by site-relative URL.

```sh
m365 spo page template remove --webUrl https://contoso.sharepoint.com/sites/project-x --url "/Shared Documents/Forms/Template.dotx"
```

## Response

The command won't return a response on success.
