更换数的.properties文件通过批处理文件 [英] replace a number in .properties file through batch file

查看:373
本文介绍了更换数的.properties文件通过批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个属性文件说abc.properties文件。它有一个文本BuildNumber = 0。我想搜索的BuildNumber并通过批处理文件replacw其与当前​​版本号值。

I have a .properties file say abc.properties file. It has a text BuildNumber=0. I want to search the BuildNumber and replacw its value with current build number through batch file.

请,如果有人可以提供帮助。我是新来的批处理脚本。

Please if someone can help. I am new to batch scripting.

任何帮助将是AP preciated。

Any help would be appreciated.

感谢

推荐答案

下面是使用批处理/ VBS脚本混合另一种方式。

Here is another way using a batch/vbs hybrid script.

@echo off
setlocal

call :FindReplace "Buildnumber=0" "Buildnumber=1.21" abc.properties
exit /b 

:FindReplace <findstr> <replstr> <file>
set tmp="%temp%\tmp.txt"
If not exist %temp%\_.vbs call :MakeReplace
for /f "tokens=*" %%a in ('dir "%3" /s /b /a-d /on') do (
  for /f "usebackq" %%b in (`Findstr /mic:"%~1" "%%a"`) do (
    echo(&Echo Replacing "%~1" with "%~2" in file %%~nxa
    <%%a cscript //nologo %temp%\_.vbs "%~1" "%~2">%tmp%
    if exist %tmp% move /Y %tmp% "%%~dpnxa">nul
  )
)
del %temp%\_.vbs
exit /b

:MakeReplace
>%temp%\_.vbs echo with Wscript
>>%temp%\_.vbs echo set args=.arguments
>>%temp%\_.vbs echo .StdOut.Write _
>>%temp%\_.vbs echo Replace(.StdIn.ReadAll,args(0),args(1),1,-1,1)
>>%temp%\_.vbs echo end with

这篇关于更换数的.properties文件通过批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆