file extension
Gives the extension of the last part of a path, with its dot.
file extension NAME
Description
Gives the text from the last dot of the last part of NAME to its end, such as .json. A last part with no dot gives an empty string, and so does a dot in a folder name only. In ztcl a name that starts with a dot and has no other dot, such as .hidden, has no extension.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| NAME | path | required | The path. |
Returns
The extension with its dot, or an empty string.
Examples
% file extension notes.json
.json
% file extension notes.tar.gz
.gz
% file extension a.b/c
% file extension .hidden
Errors
% file extension
wrong # args: should be "file extension name"
-errorcode TCL WRONGARGS
Differences from Tcl
- Tcl 8.6.16 and 9.0.4 give
.hiddenforfile extension .hidden(issue 682).
Facts
- Capability
file. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1