Spreadsheet Practice

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

Excel formula

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

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

Result on the example
one result per row in B2, filled down to B7
Works in
Microsoft 365 only
Google Sheets
Different formula, see below

See it work

The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.

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.

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

Result"q3-summary"

  1. A2"q3-summary.xlsx"

    The value in A2.

  2. -1-1

    Makes the value negative.

  3. TEXTBEFORE(A2,".",-1,,,A2)"q3-summary"

    TEXTBEFORE: Text before a delimiter.

    • textA2"q3-summary.xlsx"
    • delimiter"."
    • instance_num-1-1
    • match_mode(omitted)
    • match_end(omitted)
    • if_not_foundA2"q3-summary.xlsx"

In Google Sheets

Google Sheets needs a different formula: =REGEXREPLACE(A2,"\.[^.]*$",""). On the same data it gives the same result. Here it is running in Google Sheets mode.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=IFERROR(LEFT(A2,FIND("*",SUBSTITUTE(A2,".","*",LEN(A2)-LEN(SUBSTITUTE(A2,".",""))))-1),A2)q3-summary, Budget 2026.final, INV-1042…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)=".".

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Remove the file extension from a file name

In B2, remove the extension (the last dot and what follows it) from the file name and fill down to B7.

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,,,"").

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.