Note: The other languages of the website are Google-translated. Back to English

Excel Formula: excel extract file extension from filename

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 abbreviate words 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

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

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, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Comments (2)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This doesn't work. It's perfectly valid to have a file with multiple periods in it, such as "A vs. B.xlsx". This formula doesn't work for these files.
This comment was minimized by the moderator on the site
Yes, above formulas only work for most of files with general file names.
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations