如何替换字符串在Windows批处理文件 [英] How to replace Strings in Windows Batch file
本文介绍了如何替换字符串在Windows批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想换成以下字符串中的一个文件:
I would like to replace the following String in a file:
android:versionName="anyStringHere" >
* anyStringHere重新presents任何可能的字符串
*anyStringHere represents any possible string
使用:
android:versionName="1.04.008" >
我将如何做到这一点在清洁,可重用的方式,和preserve新线,标签和缩进在文件中?
How would I do this in a clean, reusable way, and preserve the new lines, tabs, and indentation in the file?
推荐答案
我发现,使用SED是干净的解决方案
I found that using sed was the cleanest solution
http://gnuwin32.sourceforge.net/packages/sed.htm
sed "s/android:versionName=\".*\" >/android:versionName=\"%NEW_VERSION%\" >/g" %ORIG_FILE_NAME% > %TEMP_FILE_NAME%
@move /Y %TEMP_FILE_NAME% %ORIG_FILE_NAME% >nul
这篇关于如何替换字符串在Windows批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文