({{, (RefLink[FileExtension, paclet:ref/FileExtension])["file"] 
gives the file extension for a file name.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[FileExtension, paclet:ref/FileExtension])["name.ext"] gives "ext".

(RefLink[FileExtension, paclet:ref/FileExtension]) gives the extension that appears after the last . in a file name.

If there are multiple endings to a file name, separated by ., (RefLink[FileExtension, paclet:ref/FileExtension]) gives only the last one.

(RefLink[FileExtension, paclet:ref/FileExtension]) gives "" if there is no file extension, if the file name has the form of a directory name, or ends with a . character.

(RefLink[FileExtension, paclet:ref/FileExtension]) ignores any directory specification.

(RefLink[FileExtension, paclet:ref/FileExtension]) by default assumes pathname separators and other conventions suitable for your operating system.

(RefLink[FileExtension, paclet:ref/FileExtension])[…,(RefLink[OperatingSystem, paclet:ref/OperatingSystem])->"os"] uses the conventions of the specified operating system. Possible choices are "Windows", "MacOSX", and "Unix".

(RefLink[FileExtension, paclet:ref/FileExtension]) just operates on names of files; it does not actually search for the file specified.

(RefLink[FileExtension, paclet:ref/FileExtension])[(RefLink[File, paclet:ref/File])["file"]] is also supported.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Find the file extension of a string:

FileExtension["file.txt"]

OpenersExampleSection1(Spacer1)Scope  (1)

Find the extension of the file specified by the (RefLink[File, paclet:ref/File]) object:

FileExtension[File["file.txt"]]

OpenersExampleSection3(Spacer1)Possible Issues  (1)

The period is not part of the file extension:

FileExtension["file."]

Or the file base name:

FileBaseName["file."]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FileFormat, paclet:ref/FileFormat])  ▪  (RefLink[FileBaseName, paclet:ref/FileBaseName])  ▪  (RefLink[FileNameSplit, paclet:ref/FileNameSplit])  ▪  (RefLink[Import, paclet:ref/Import])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Operations on File Names, paclet:guide/OperationsOnFileNames])}})}})