forked from sergueik/selenium_java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml_replace.cmd
More file actions
32 lines (31 loc) · 916 Bytes
/
Copy pathxml_replace.cmd
File metadata and controls
32 lines (31 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@echo off
REM replacing text of a specific node with CMD
setlocal enableextensions enabledelayedexpansion
set FILE=file.xml
set RESULT=file.xml.updated
set TAG=^<server^>
set TEXT=%COMPUTERNAME%
for /f "delims=" %%a in ('more %FILE%') do @(
echo "%%~a"|find /i "%TAG%" >nul
if ERRORLEVEL 1 @echo %%a >> %RESULT% && goto :NEXTLINE
for /f "tokens=1,3 delims=><" %%b in ("%%~a") do @echo:^<%%b^>%TEXT%^<%%c^> >> %RESULT%
:NEXTLINE
)
move /y %RESULT% "%FILE%" > NUL
goto :EOF
REM somewhat weirdified syntax
REM origin http://forum.oszone.net/thread-322910.html
set "FILE=file.xml"
set "RESULT=file.xml.updated"
set "TAG=<server>"
set "TEXT=%COMPUTERNAME%"
<"%FILE%">%result% (for /f "delims=" %%a in ('more') do @(
echo "%%~a"|>nul find /i "%TAG%" && (
for /f "tokens=1,3 delims=><" %%b in ("%%~a") do @echo:^<%%b^>%TEXT%^<%%c^>
) || (
echo %%a
)
)
)& >nul move %RESULT% "%FILE%"
goto :EOF
exit