Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

Excel Formula: excel extract file extension from filename

Author Sun Last modified

In some cases, you may want to extract the file extensions form a list of filenames in Excel worksheet. Here in this tutorial, introduces two different formulas to quickly handle this job, also you can realize how the formulas work in Excel.
doc extract extension from file name 5

Formula 1 Using SEARCH, RIGHT and REPLACE functions

Generic formula:

REPLACE(RIGHT(filename,5),1,SEARCH(".",RIGHT(filename,5)),"")

Arguments

Filename: the filename you want to extract the extension.

How this formula work

To extract the extension of filename in cell B3, please use the formula:

=REPLACE(RIGHT(B3,5),1,SEARCH(".",RIGHT(B3,5)),"")

Press Enter key to the cell B8.to extract the extension.
doc-extract-extension-from-file-name-1

Explanation

RIGHT function is used to extract text from right side of a given text. Here RIGHT(B3,5) extracts 5 characters from right side of text in cell B3 since the longest length of extension is not longer than 5-digit. It returns “.xlsx”.

SEARCH function returns the location of the specific character or text from the given text string. Here SEARCH(".",RIGHT(B3,5)) finds the location of “.” in the text string “.xlsx” and returns 1.

REPLACE function finds and replaces characters based on given location from text string with a new text. REPLACE(RIGHT(B3,5),1,SEARCH(".",RIGHT(B3,5)),"") can be seen as REPLACE(".xlsx",1,1,""), it finds first character of the text string “.xlsx”, and replaces it with nothing.
doc extract extension from file name 2

Formula 2 Using LEN, RIGHT and FIND functions

Generic formula:

RIGHT(filename,LEN(filename)-FIND(".",filename))

Arguments

Filename: the filename you want to extract the extension.

How this formula work

To extract the extension of filename in cell B3, please use the formula:

=RIGHT(B3,LEN(B3)-FIND(".",B3))

Press Enter key to the cell B8.to extract the extension.
doc extract extension from file name 3

Explanation

FIND function returns the starting position of a string inside another one. FIND(".",B3) find the starting position of “.” in cell B3, it returns 15.

LEN function used to count the number of characters.

RIGHT function is used to extract text from right side of a given text. Here =RIGHT(B3,LEN(B3)-FIND(".",B3)) can be seen as RIGHT(B3,18-15), it extracts 3 characters from right side of the text in cell B3.
doc extract extension from file name 4

Sample File

doc sampleClick to download sample file


Relative Formulas


Relative Functions


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ...
Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup...
Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List...
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...


Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.