---
title: "parse_filename function in Strata | Oplema"
description: "Return the last component of a path, such as c.txt for a/b/c.txt. Set trim_extension to true to drop the extension. Use it in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/parse-filename"
updated: "2026-11-04"
---

# parse\_filename

Return the last component of a path, such as c.txt for a/b/c.txt. Set trim\_extension to true to remove the file extension. The optional separator can be system, both\_slash (default), forward\_slash or backslash.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
parse_filename('path/to/file.csv', true, 'forward_slash')
```

### Result

```
'file'
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | file |

## Arguments and types

```
parse_filename(string, trim_extension, separator)
```

**string**

Text

**trim\_extension**

True or false, Text

**separator**

Text

Supported signatures (4)

```
parse_filename(string: VARCHAR) → VARCHAR
parse_filename(string: VARCHAR, trim_extension: BOOLEAN) → VARCHAR
parse_filename(string: VARCHAR, trim_extension: BOOLEAN, separator: VARCHAR) → VARCHAR
parse_filename(string: VARCHAR, trim_extension: VARCHAR) → VARCHAR
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[parse\_dirpath

Return a path up to its last slash, such as a/b for a/b/c.txt. The optional separator can be system, both\_slash (default), forward\_slash or backslash.

](https://oplema.com/docs/strata/functions/parse-dirpath)[parse\_path

Return the directories and filename in a path as a list. The optional separator can be system, both\_slash (default), forward\_slash or backslash.

](https://oplema.com/docs/strata/functions/parse-path)[parse\_dirname

Return the top-level directory name from a path. The optional separator can be system, both\_slash (default), forward\_slash or backslash.

](https://oplema.com/docs/strata/functions/parse-dirname)[regexp\_matches

Check whether text contains a match for a regular expression. An optional argument sets regex options.

](https://oplema.com/docs/strata/functions/regexp-matches)

[Browse text](https://oplema.com/docs/strata/functions#text) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/text.html#parse_filenamestring-trim_extension-separator)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
