Disabling auto-extension for certain file types

When I save a C++ makefile on MacOS (I'm using Sequoia) the suffix .cpp is automatically added.


When I try to delete the suffix, MacOS just hides the extension.


I have to go into 'Get Info', de-select 'hide extension' and then delete the suffix there.


Is there something I can do to stop this automatic behaviour, as it's a pain!


Thank you.

Mac Pro, macOS 14.5

Posted on Nov 16, 2025 10:47 AM

Reply
11 replies

Nov 16, 2025 3:38 PM in response to robbie_moose

You do know that if there is no extension your Mac won't know what application created it and to open it with.


That being said you can create an automator app to change the extension to none:



It'll work like this when you drag and drop a file on the app:



It will change the icon to some generic icon depending on what the file was originally. In this case it turned the pdf file into a SIT file that was opened by TextEdit when double clicked on.


Nov 17, 2025 7:24 AM in response to robbie_moose

Just as etresoft said: "C++ Makefile" is an oxymoron. You either have a C++ file (in which case it SHOULD have the extension .cpp) or a Makefile (which is typically just named like this: "Makefile", without extension).


Also: you don't "save in macOS", you save FROM an application, and that is where you should make the proper arrangements to give the file the desired name, including extension (or lack thereof).


SO, Please start by telling us which application is being used to edit and save these files, and whether you are discussing actual C++ files, or Makefiles.

Nov 17, 2025 10:25 AM in response to robbie_moose

Thank you everyone for your kind attention, and I'm sorry that I was so unclear in my original post.


I am creating a makefile within SublimeText, to automate the compilation of my C++ code. When I save from SublimeText it is automatically being given the extension suffix .cpp upon saving.


When I rename the file within MacOS (Sequoia) to remove the extension suffix, it is instead just being hidden, which requires me to 'Get Info', unhide the extension and then delete it there.


I hope that my use of language is correct and that my question now makes sense.


(Old Toad: thank you for your help. This'll definitely do the job as a work-around. I'm asking SublimeText's forums for help on saving without any extension which might help as I think both Sublime and MacOS are conspiring to do this to my file.)

Nov 17, 2025 11:53 AM in response to robbie_moose

Sublime Text 4 (build 4200) does not automatically assign a .cpp extension to anything. You can enter plain text as your Makefile rules and then save it as just Makefile, or actual C++ source code as plain text and save as .cpp. Never remove or hide the extensions of your source code.


If you are attempting to create a Sublime Text 4 build system, that is saved as Makefile.sublime-build and with the correct syntax, you can just type cmd+B to run that Makefile.sublime-build. I would encourage you to review the Sublime Text 4 documentation on Build Systems.

Nov 17, 2025 12:14 PM in response to VikingOSX

VikingOSX wrote:

Sublime Text 4 (build 4200) does not automatically assign a .cpp extension to anything.

I know. That's why I'm asking here, as Sublime Text 4 (build 4192) automatically assigned a .cpp extension to the file I saved as just Makefile.


I never remove or hide extensions of my sourcecode. I removed the extension that was automatically added to Makefile.


I've just tried again and Sublime hasn't added .cpp this time. I'll monitor and see if it was just some freak bug.

Disabling auto-extension for certain file types

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.