How to Rename a .txt File on Mac Without Changing the Extension
By default, macOS hides file extensions in Finder. That means a file called "notes.txt" just shows up as "notes." When you click to rename it, you might type a new name and hit Enter without realizing you've only changed the name before the dot — or worse, you delete the whole thing including the hidden extension and end up with a file macOS no longer recognizes.
The safest way: show extensions first
Go to Finder → Settings (or Preferences on older macOS) → Advanced. Check the box that says Show all filename extensions. From this point on, extensions are always visible in Finder, so you can see exactly what you're editing when you rename a file.
With extensions visible, click once on a file to select it, then press Return to start renaming. The filename field highlights the name portion only — not the extension. Type the new name and press Return. The .txt stays intact.
Renaming from Terminal
mv ~/Desktop/old-name.txt ~/Desktop/new-name.txtTerminal's mv command is precise — you type exactly what the new filename should be, extension included. There's no hidden behavior. This is the most reliable method when you need to be certain about the result.
What to do if you already removed the extension
If you accidentally renamed a file to just "notes" with no extension, macOS may show it with a blank document icon and refuse to open it normally. Fix it by clicking the file once, pressing Return to rename, and typing the full name with the extension: notes.txt. macOS will ask if you're sure you want to add an extension — confirm it.
Alternatively from Terminal:
mv ~/Desktop/notes ~/Desktop/notes.txtBatch renaming .txt files
Finder has a built-in batch rename feature. Select multiple files, right-click, and choose Rename. You can add text, replace text, or format names with a counter. For more complex batch renaming, the Terminal command rename (installable via Homebrew) gives you regex-based renaming across whole directories.
Enabling "Show all filename extensions" in Finder is the single best preventative measure. It makes the extension visible at all times and makes Finder's rename behavior predictable. One checkbox, permanent fix.