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, 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.
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) → VARCHARThe 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.
Function metadata from DuckDB, used under the MIT license.