os.Path.baseName

Returns the last element of a path.

Syntax

os.Path.baseName(
     path STRING)
  RETURNS STRING
  1. path 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.