Basename - Maple Help

FileTools

 Extension
 get file extension from filepath
 Basename
 get base name from filepath

 Calling Sequence Extension(path,options) Basename(path)

Parameters

 path - string; filepath, relative or absolute options - (optional) options as specified below

Options

 • uppercase=truefalse
 If true, return the file extension in uppercase. As file extensions may be in mixed case, this option may simplify code handling file extensions.

Description

 • The Extension and Basename commands return the extension and base name, respectively, of the file referenced by the filepath, path.
 • Extension("name.ext") returns "ext" and Basename("name.ext") returns "name".  Both commands omit any directories listed in path.
 • The filepath, path, must be syntactically correct but is not required to correspond to an existing file or directory.

Examples

 > $\mathrm{FileTools}:-\mathrm{Extension}\left("sampleData.csv"\right)$
 ${"csv"}$ (1)
 > $\mathrm{FileTools}:-\mathrm{Basename}\left("sampleData.csv"\right)$
 ${"sampleData"}$ (2)

The following path does not correspond to an existing file.

 > $\mathrm{FileTools}:-\mathrm{Basename}\left("/Images/Butterfly.jpg"\right)$
 ${"Butterfly"}$ (3)
 > $\mathrm{FileTools}:-\mathrm{Extension}\left("/Images/Butterfly.jpg"\right)$
 ${"jpg"}$ (4)
 > $\mathrm{FileTools}:-\mathrm{Extension}\left("/Images/Butterfly.jpg",\mathrm{uppercase}\right)$
 ${"JPG"}$ (5)

Compatibility

 • The FileTools[Extension] and FileTools[Basename] commands were introduced in Maple 18.