开发者

Problem with white spaces in batch file

I am trying to search a substring and replace it with another string in entries file of SVN using following code However when code encounter some thing like ' '(space when seen in notepad)or '##'(when seen in notepad++) code replaces it with 'ECHO is off.' How to get around this problem.

@echo off

setlocal enabledelayedexpansion

set LOCATION=C:\RUNTIME_DATA\

set OUTTEXTFILE=test_out.txt

set oldstr3=SetWorkflowVariable

set newstr3=SetProcessVariable

set oldstr5=

set newstr5=

FOR /r %LOCATION% %%x IN (*.*) do (

FOR /f "tokens=1,* delims=¶" %%A in ('"type %%x"') do (

SET string=%%A

SET modified=!string:%o开发者_高级运维ldstr3%=%newstr3%!

SET modified=!modified:%oldstr5%=%newstr5%!

echo !modified! >> %OUTTEXTFILE%
)

del %%x

copy %OUTTEXTFILE% %%x

del %OUTTEXTFILE%

echo location  %%x >> LOG_FOR_ENTRIES_%date:~4,2%%date:~7,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,2%%.txt

)


Replace echo !modified! with echo.!modified!. The dot makes it clear that you want to echo something. It will not be printed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜