PlatformIO Community

Rename bin file on build

Is there a way to rename the bin file to include the DBUILD_TAG when targeting a specific build?

e.g. in the platformio.ini I have the a entry version = -DBUILD_TAG=2.2. I would like this to be concatenated to the bin file when doing a release build so that firmware.bin becomes firmware_v2.2.bin

Sure, take a look at Advanced Scripting. You need an extra script


build_tag = "v2.2"

env.Replace(PROGNAME="firmware_%s" % build_tag)
1 Like

Thanks Ivan

I got it working using a python script that renames it and moves it to a release location. Working like a well oiled machine now :slight_smile:

1 Like

I can’t get this to work.
This is show in the output
warning: Calling missing SConscript without error is deprecated.
Transition by adding must_exist=0 to SConscript calls.
Missing SConscript ‘’

So what exactly is your project file structure and the content of your extra script?

Thanks Max for your help, here the info

the content of

Import("env", "projenv")
# access to global construction environment
# access to project construction environment
my_flags = env.ParseFlags(env['BUILD_FLAGS'])
defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}
env.Replace(PROGNAME="firmware_test%s" % defines.get("VERSION")) 

location of the file
Screenshot 2020-04-10 09.26.18

my platform.ini

platform = espressif32
board = featheresp32
framework = arduino
lib_deps =
build_flags = -D VERSION=1.1.3
extra_scripts =
monitor_speed = 115200


Screenshot 2020-04-10 09.28.06

So in your platformio.ini you instruct PIO to execute but in your project there’s no such file, but a instead. You just have a typo :sweat_smile:.

1 Like

:blush: thanks a lot

Did you use this script:

my_flags = env.ParseFlags(env[‘BUILD_FLAGS’])
defines = {k: v for (k, v) in my_flags.get(“CPPDEFINES”)}


env.Replace(PROGNAME=“firmware_%s” % defines.get(“VERSION”))

I just don’t get this to work(New to platformio)
Where do I put what?
Any advice will be greatly appreciated,
Thank you in advance.