os.Path.baseName

Returns the last element of a path.

Syntax

os.Path.baseName(
   filename STRING)
  RETURNING result STRING
  1. filename is the name of the file.

Usage

This method extracts the last component of a path provided as argument.

For example, if you pass "/root/dir1/file.ext" as the parameter, it will return "file.ext".

See Example 1: Extracting the parts of a file name for more examples.