How to Get the File Extension from a File Name in Excel

Extract file extensions — even from names with several dots — and the name without its extension, from a shared-drive file list.

You will learn to

  • Extract the extension from a simple file name
  • Use the last dot when names contain several
  • Return the file name without its extension

How it works

The extension is everything after the last dot of a file name. In Excel 365, =TEXTAFTER(A2,".",-1) handles names with any number of dots: "contract.v2.final.pdf" returns "pdf". The -1 tells TEXTAFTER to count dots from the end. Wrap it in LOWER so "JPG" and "jpg" group together when you count file types.

The mirror formula =TEXTBEFORE(A2,".",-1) returns the file name without its extension — handy for renaming lists or matching files across formats. In older Excel, the trick =TRIM(RIGHT(SUBSTITUTE(A2,".",REPT(" ",100)),100)) gets the text after the last dot.

=TEXTAFTER(A2,".",-1)