0
我試圖搜索一個子字符串,並用SVN的條目文件中的另一個字符串替換它,使用以下代碼 但是當代碼遇到「'(在記事本中看到空間時)或' ##'(在記事本++中看到)代碼將其替換爲'ECHO is off'。 如何解決這個問題。批處理文件中的空格問題
@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:%oldstr3%=%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
)
非常感謝。它非常有幫助。 – Enosh 2011-03-16 15:59:12
@開頭:對不起,我不明白你的意思。 – Benoit 2011-03-16 16:01:34