FileBaseName

FileBaseName["file"]

gives the base name for a file without its extension.

Details and Options

  • FileBaseName["name.ext"] gives "name".
  • FileBaseName drops all directory specifications.
  • FileBaseName by default assumes pathname separators and other conventions suitable for your operating system.
  • FileBaseName[,OperatingSystem->"os"] uses the conventions of the specified operating system. Possible choices are "Windows", "MacOSX", and "Unix".
  • FileBaseName just operates on names of files; it does not actually search for the file specified.
  • FileBaseName[File["file"]] is also supported.

Examples

open allclose all

Basic Examples  (2)

Find base name of the file:

In[1]:=
Click for copyable input
Out[1]=

Split off the last extension:

In[1]:=
Click for copyable input
Out[1]=

Scope  (3)

Possible Issues  (1)

See Also

FileExtension  FileNameTake  FileNameSplit  FileNameDepth  FileNames

Introduced in 2008
(7.0)
| Updated in 2016
(11.0)