为pdb的命名添加版本信息
- 从目标文件读入第一行内容
- 然后截取16位后面的字符
- 然后在for循环里面用逗号分割截取到的目标字符串,存在4个token里面
- 由于in里面的表达式,只进行一次,所以这个for循环是只执行了一次,拼出版本号的数字,更新到变量里面
- 需要注意的是,如果像下面一样,在语句里面去用这些变量,可能需要使用延迟变量的用法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
if "%2"=="--xybase" ( set file_name=XYBase.pdb set /p content= < build-tools\XYBase.h set ver=!content:~16! for /f "tokens=1,2,3,4 delims=," %%a in ("!ver!") do ( set var=%%a%%b%%c%%d ) echo copy: !var!_!file_name! copy /Y "%src_release_path%\!file_name!" "%dst_path%\%dir_name%\!var!_!file_name!" set file_name=XYInteractive.pdb set /p content= < build-tools\XYInteractive.h set ver=!content:~16! for /f "tokens=1,2,3,4 delims=," %%a in ("!ver!") do ( set var=%%a%%b%%c%%d ) echo copy: !var!_!file_name! copy /Y "%src_release_path%\!file_name!" "%dst_path%\%dir_name%\!var!_!file_name!" set file_name=js.pdb set /p content= < build-tools\kernelver.h set ver=!content:~16! for /f "tokens=1,2,3,4 delims=," %%a in ("!ver!") do ( set var=%%a%%b%%c%%d ) echo copy: !var!_!file_name! copy /Y "%src_xunyoukernel_path%\!file_name!" "%dst_path%\%dir_name%\!var!_!file_name!" set file_name=Game_Find.pdb set /p content= < build-tools\XunYouGameFindVer.h set ver=!content:~16! for /f "tokens=1,2,3,4 delims=," %%a in ("!ver!") do ( set var=%%a%%b%%c%%d ) echo copy: !var!_!file_name! copy /Y "%src_findgame_path%\!file_name!" "%dst_path%\%dir_name%\!var!_!file_name!" set file_name=XYNewGame.pdb set /p content= < build-tools\XYNewGameVer.h set ver=!content:~16! for /f "tokens=1,2,3,4 delims=," %%a in ("!ver!") do ( set var=%%a%%b%%c%%d ) echo copy: !var!_!file_name! copy /Y "%src_newgame_path%\!file_name!" "%dst_path%\%dir_name%\!var!_!file_name!" exit /b 0 ) |
- 如果是单独使用,不用延迟变量也可以
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@echo off SETLOCAL EnableDelayedExpansion set /p content=< kernelver.h echo %content% set ver=%content:~16% echo %ver% set var= for /f "tokens=1,2,3,4 delims=," %%a in ("%ver%") do ( set var=%%a%%b%%c%%d ) echo %var% pause |
本文为原创文章,版权归Aet所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ 语法函数命令二10/02
- ♥ 语法函数命令三06/10
- ♥ Windows线程同步相关03/10
- ♥ 数据结构_二叉树节点10/16
- ♥ Linux_ 命令大全 Windows System03/16
- ♥ 【华东师大版八年级下册】05/16