# How to remove the file extension from a file name in Excel

Keep the text before the last dot: =TEXTBEFORE(A2,".",-1,,,A2). Names without a dot come back unchanged.

**Excel:** `=TEXTBEFORE(A2,".",-1,,,A2)` (Microsoft 365 only)

**Google Sheets:** `=REGEXREPLACE(A2,"\.[^.]*$","")`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| File name | Without extension |
| q3-summary.xlsx |  |
| Budget 2026.final.xlsx |  |
| INV-1042.pdf |  |
| notes.txt |  |
| IMG_4471.JPG |  |
| README |  |

Formula in B2, filled to B7: `=TEXTBEFORE(A2,".",-1,,,A2)`

Result: q3-summary; Budget 2026.final; INV-1042; notes; IMG_4471; README

## How it works

TEXTBEFORE with instance `-1` keeps everything before the last dot, so dots inside the name ("Budget 2026.final") survive. The sixth argument is what to return when there is no dot: the original name.

In Google Sheets, REGEXREPLACE deletes a dot followed by non-dot characters at the end of the text.

## Other ways

- `=IFERROR(LEFT(A2,FIND("*",SUBSTITUTE(A2,".","*",LEN(A2)-LEN(SUBSTITUTE(A2,".",""))))-1),A2)`: Works in every version: mark the last dot with * and keep everything to its left.

## Common mistakes

- Cutting at the first dot loses part of the name: "Budget 2026.final.xlsx" becomes "Budget 2026".
- Names that start with a dot, like ".gitignore", come back empty. Check for them with `LEFT(A2)="."`.

## Questions

**How do I change the extension?**

Add the new one: `=TEXTBEFORE(A2,".",-1,,,A2)&".csv"`.

**How do I get only the extension?**

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

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/remove-file-extension
