Go to main content

filename

Return the filename.

FILENAME

NAME

filename - Return the filename.

SYNOPSIS

filename (ext:bool, "file", …)

DESCRIPTION

This function returns the filename portion of a file. It remove the direction and extention.

If ext is true, filename will return the extention of the file.

ex: filename(ext:true, file);

The order is important, THIS WILL NOT WORK: filename(file, ext:true);

You can have multiple ext parameter as in:

filename(file1, ext:true, file2, ext:false, file3);

If multiple files are passed, the function return an array.

If only one file is passed, the function return a string.

The parameter ext is valid from version 5.123.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{ filename('a','b.txt', "/a/c.txt", "/a/d", "aa", "bb.png", "/aa/cc.txt", "/aa/dd", "/a/.ext"); }_}.

return 

res=["a","b","c","d","aa","bb","cc","dd",""].

SEE ALSO

{{ include("includes/files.sn") }}

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2015-02-03 21:24:14 laplante@sednove.com

1.1 2019-12-04 laplante@sednove.com : Add parameter ext

Edit

© 2021 extenso Inc. All rights reserved.