How do I change the output.hex file name in MPLAB® X IDE?

You can add a post step to the build process to copy the files to a different place. You can rename the files in the process if you want to. If you have a directory called c:\tmp and you want to put your HEX and ELF there, add:

cp ${ImagePath} c:/tmp

to the post step in the Building node of the Project Properties window:

renamehex1.jpeg

When you build for production (click the Build Project (hammer) button or the program button), the HEX will end up in c:\tmp. When you build for debug (click Build for Debugging or use the build debug image):

renamehex2.jpeg

The ELF (or COF) will end up in c:\tmp.

If you want to create the dest directory, in case it does not exist:

renamehex3.jpeg

MPLAB® X puts the GnuWin32 tools in your path; therefore, cp will be there and gnumkdir is nothing more than GNU mkdir renamed, so it does not clash with the Windows native mkdir. If you are in Linux® or OS X®, we use mkdir and cp as found in the native system.

You can do fancier things if you call a program to do the copying and renaming. At the bottom of the page, you will find a download link to an example of a project that calls copyWithDate (a batch file that is part of the project):

renamehex4.jpeg

It will copy the HEX or ELF to a file in the project directory whose base name is the current date (like 02_19_2015.hex). You can do similar things if you run a Python, Ruby, Perl, or another script that takes as arguments the macros it needs and does whatever you want.

Example Project

© 2025 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.