basename

Get the basename of a file or directory path

String basename(File, [String])
String basename(Directory, [String])

Returns the "basename" of a file or directory - the name after the last directory separator in the path.

The optional second parameter specifies a literal suffix to remove from the file name. If the file name does not end with the specified suffix then it is ignored.

Parameters

  1. File|Directory: Path of the file or directory to read. If the argument is a String, it is assumed to be a local file path relative to the current working directory of the task.
  2. String: (Optional) Suffix to remove from the file name.

Returns: The file's basename as a String.

Example: test_basename.wdl

version 1.3

workflow test_basename {
  output {
    Boolean is_true1 = basename("/path/to/file.txt") == "file.txt"
    Boolean is_true2 = basename("/path/to/file.txt", ".txt") == "file"
    Boolean is_true3 = basename("/path/to/dir") == "dir"
  }
}

Example input:

{}

Example output:

{
  "test_basename.is_true1": true,
  "test_basename.is_true2": true,
  "test_basename.is_true3": true
}