Replacing symbols or line break in windows batch -
i found batch script changes string string.
below batch script changes every 'bath' '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= /f "tokens=1,* delims=¶" %%a in ( '"type %intextfile%"') ( set string=%%a set modified=!string:%searchtext%=%replacetext%! echo !modified! >> %outtextfile% ) del %intextfile% rename %outtextfile% %intextfile%
(copied how replace substrings in windows batch file)
but want changing every '△▽' 'newline , xy' in test.txt example, if test.txt is
abc△▽def
then result should be
abc xydef
before attacking problem, tried easier-looking problem : changing every '△▽' 'xy'. easier-looking problem looks difficult me. changed bath △▽, , hello xy in above script. script didn't work. reason guess - since △,▽ symbols.
could teach me how express symbol or line break, tab in refered batch script ?
the white up-points triangle encoded in utf-8 3 bytes hexadecimal code values e2 96 b3
, white down-points triangle e2 96 bd
.
how can find , replace text in file using windows command-line environment? contains several answers suggestions on how replace strings in batch mode using console applications or windows standard commands.
i wrote favorite tool such replaces, xchang32.exe clay's utilities win32.
this console application replaces bytes bytes , can used therefore file type, binary files text files of encoding.
this tool following parameters makes replace want.
xchang32.exe test.txt "^xe2^x96^xb3^xe2^x96^xbd" "^x0d^x0axy"
all △▽
replaced carriage return (0d) , line-feed (0a) , characters xy
in file test.txt
. in case of file test.txt
unix file using line-feed line terminator, remove ^x0d
replace string.
of course same replacement done utf-8 aware text editor ultraedit has replace in files command capable replace utf-8 encoded strings in files of folder or folder tree.
Comments
Post a Comment