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 is you want to. If you have a dir 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:


When you build for production (hit the hammer button or the program button), the .hex will end up in c:\tmp. When you build for debug (hit the debug-run button or use the build debug image):


the .elf (or .cof) will end up in c:\tmp.
If you want to create the dest directory in case it does not exist:


MPLAB X puts the GnuWin32 tools in your path. So, cp will be there. And gnumkdir is nothing that the GNU mkdir renamed so it does not clash with the Windows native mkdir. If you are in Linux/MacOSX, 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/renaming. At the bottom of the page you can download an example of a project that calls copyWithDate (a batch file that is part of the project):


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/whatever script that takes as arguments the macros it needs and does whatever you want.

Example Project

© 2017 Microchip Technology, Inc.
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.