STEM base file name without directory or suffix

s = stem(p) returns the stem (base name) of the file specified by the path p.
leading dot filenames are allowed.

Contents

Inputs:

Output:

Note: fileparts() was about 100x faster then using multiple steps with pattern.

function s = stem(filepath)
arguments
  filepath string
end

[~, s, e] = fileparts(filepath);

i = stdlib.strempty(s);
s(i) = e(i);

end