当前位置:编程学习 > C#/ASP.NET >>

如何用bat替换文本中的字符串

在command.cs文件中,用"Pb" 来替换所有"Park".怎么用bat实现啊?求助,跪谢。 --------------------编程问答-------------------- 参考 http://hi.baidu.com/rsent/blog/item/b2cb5322356c3339d42af1e0.html --------------------编程问答-------------------- set ext_name=C:\Users\TAS3\Desktop\test.cs
set old_char="PB_30s.avi"
set new_char="aaaaaaaaaaaaaaaaaaaa"

echo %ext_name%
echo %old_char%
echo %new_char%


if "%ext_name%" == "" goto warning
if "%old_char%" == "" goto warning
if "%new_char%" == "" goto warning
setlocal enabledelayedexpansion
set /a a=1
for %%x in (%ext_name%) do ( 
 for /f "tokens=*" %%i in (%%x) do (
         set "var=%%i"
  if not !var!.==. (
     set "var=!var:%old_char%=%new_char%!"
     echo !var!!>>C:\Users\TAS3\Desktop\test.cs
  )
 )
set /a a=!a!+1
)
goto replacefinish

:warning
echo the tool replaceChar requires 3 command line arguments:
echo 1) ext name of file in which you want to replace some characters
echo 2) characters you want to be replaced
echo 3) new characters with which you want to replace some characeters

:replacefinish
echo ***** Finish repalce the test video file name *****
这是我的代码,我发现可以替换了,但是又在文件中生成了一遍,并没有把以前的删除掉。怎样既替换又删除呢?

引用楼主  的回复:
在command.cs文件中,用"Pb" 来替换所有"Park".怎么用bat实现啊?求助,跪谢。
补充:.NET技术 ,  .NET Framework
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,