【嵌入式】Keil重命名生成的bin文件的bat脚本

@echo off

::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
::选择需要输出的后缀格式(多选一)
::尾缀添加年月日时分秒(_20200101_010101)
::set format=_%ymd%_%hms%
::尾缀添加版本号
set format=_v1.0.0
::<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
::相关本地设置
::1.指定bin文件路径
set bin_path=%cd%\_bulid
::2.指定bin文件名(不需要.bin)
set bin_name=template
::3.keil的安装路径
set keil_path=D:\Software\Keil_v5
::<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
::拷贝到当前目录
::set copy_path="%cd%"
::拷贝到指定目录
::set copy_path=C:\Users\Desktop\target
::<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

::进入路径
cd %bin_path%
echo %bin_path%

%keil_path%\ARM\ARMCC\bin\fromelf.exe --bin -o "%bin_name%.bin" "%bin_name%.axf"
%keil_path%\ARM\ARMCC\bin\fromelf.exe --text -a -c -o "%bin_name%.asm" "%bin_name%.axf"

::年月日(如20110101)
set ymd=%date:~0,4%%date:~5,2%%date:~8,2%
::时分秒(如101721)
set hms=%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%

::重命名文件
set new_file=%bin_name%%format%
if exist %new_file%.bin del %new_file%.bin
ren %bin_name%.bin %new_file%.bin

%keil_path%\ARM\ARMCC\bin\fromelf.exe --bin -o "%bin_name%.bin" "%bin_name%.axf"

::执行拷贝
::echo %copy_path%
::copy %new_file%.bin %copy_path%

你可能感兴趣的:(【嵌入式】Keil重命名生成的bin文件的bat脚本)