.bat file can't escape character -


i have problem in script:

@echo on setlocal enabledelayedexpansion pushd c:\users\oskars.abuhovs\desktop\testjstoreplace /f "delims=" %%a in ('dir /b /a-d-h-s') (   set newfile=c:\users\oskars.abuhovs\desktop\tempjs\%%a   if exist !newfile! del /f /q !newfile!   /f "delims=" %%l in (%%a) (     set newline=%%l     echo !^newline:dojo/i18n=ggggggggg^^!dddd! >> !newfile!   ) ) popd pause 

the problem in row:

echo !^newline:dojo/i18n=ggggggggg^^!dddd! >> !newfile! 

where character ! not escaped, read in setlocal enabledelayedexpansion ! character should escaped using ^^, not happening. how can escape character?

edited:

i want replace part of string in files. particular string dojo/i18n should replaced string, contains !. example dojo/i18n!mycomputer.

whole script reads files folder, search every file line line searching string: dojo/i18n, when found, string should replace mentioned text dojo/i18n!mycomputer, contains !. tried escaping ! character 2 ^^ supposed work when setlocal enabledelayedexpansion, combination: ^^! not work in line, when tried simple echo ^^! worked.

so asking how escape ! character in line?

thanks in advance!

this might work you:

@echo off setlocal enabledelayedexpansion pushd "c:\users\oskars.abuhovs\desktop\testjstoreplace" /f "delims=" %%a in ('dir /b /a-d-h-s') (   set "newfile=c:\users\oskars.abuhovs\desktop\tempjs\%%~a"   if exist "!newfile!" del /f /q "!newfile!"   /f "delims=" %%l in ("%%~a") call:doline "%%~l" "!newfile!" ) popd pause goto:eof  :doline setlocal disabledelayedexpansion set "newline=%~1" echo %newline:dojo/i18n=ggggggggg!dddd% >> "%~2" endlocal goto:eof 

Comments