---
title: "parse_dirname function in Strata | Oplema"
description: "Return the top-level directory name from a file path, such as path from path/to/file.csv. Use it in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/parse-dirname"
updated: "2026-11-04"
---

# parse\_dirname

Return the top-level directory name from a path. 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_dirname('path/to/file.csv', 'system')
```

### Result

```
'path'
```

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

## Arguments and types

```
parse_dirname(path, separator)
```

**path**

Text

**separator**

Text

Supported signatures (2)

```
parse_dirname(path: VARCHAR) → VARCHAR
parse_dirname(path: VARCHAR, separator: 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\_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.

](https://oplema.com/docs/strata/functions/parse-filename)[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)[regexp\_extract

Return the part of text that matches a regular expression, or empty text if there is no match. An optional constant group number picks a capturing group, and regex options can follow.

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

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

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