【发布时间】:2015-07-31 09:24:03
【问题描述】:
谁能建议我如何使用脚本替换文件中的字符串?该字符串包含一些特殊字符(例如:> “ ” )。
我的 searchString 如下所述
launcher.properties" />
我的新字符串如下所述
launcher.properties" > <Permission User="Everyone" GenericAll="yes" /> </File>
当我使用下面的脚本时出现错误
@echo off &setlocal
set "search=launcher.properties" />"
set "replace=launcher.properties" > <Permission User="Everyone"
GenericAll="yes" /> </File> "
echo replaceing hte string....2222
set "textfile=home.wxs"
set "newfile=home_t2.wxs"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
echo(!line!
endlocal
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%
出现以下错误:
The system cannot find the path specified.
< was unexpected at this time.
请帮帮我。
【问题讨论】:
标签: string file batch-file replace