I found a batch script that changes a string to another string.
Below batch script changes every 'bath' to 'hello' in test.txt
@echo off
setlocal enabledelayedexpansion
set INTEXTFILE=test.txt set OUTTEXTFILE=test_out.txt
set SEARCHTEXT=bath
set REPLACETEXT=hello
set OUTPUTLINE=
for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
SET string=%%A
SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!
echo !modified! >> %OUTTEXTFILE%
)
del %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%
(copied from How to replace substrings in windows batch file)
But what I want to do is changing every '△▽' to 'newline and xy' in test.txt For example, if test.txt is
abc△▽def
then the result should be
abc
xydef
Before attacking this problem, I tried easier-looking problem : changing every '△▽' to 'xy'. But this easier-looking problem looks even difficult to me. I just simply changed bath to △▽, and hello to xy in the above script. Then the script didn't work. The reason I guess is - since △,▽ are symbols.
Could you teach me how to express symbol or line break, tab in the refered batch script ?
Aucun commentaire:
Enregistrer un commentaire