This might work for you, if you put lines always to print in the %dict%
file:
@ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION
SET "file=file"
SET "new=new"
SET "dict=dictionary"
(FOR /f "tokens=1*delims=:" %%a IN ('findstr /n "^" "%file%"') DO (
SET "nr=%%a"
SET "line=%%b"
SET "this="
FINDSTR /l "!line!" "%dict%" >NUL 2>&1&& ECHO(!line! || (
FOR /f "tokens=1*delims==" %%x IN ('set "$" 2^>nul') DO IF !line!==%%y SET "this=1"
IF "!this!"=="" (
ECHO(!line!
SET "$!nr!=!line!"
)
)
))>"%new%"
TYPE "%new%"
..shell session:
>type file
<bookstores>
<book id="parent">
<name="it1"/>
<name="it1"/>
<name="it2"/>
</book>
<book id="child">
<name="it1"/>
<name="it1"/>
<name="it2"/>
<name="it3"/>
</book>
</bookstores>
>type dictionary
</book>
>script.bat
<bookstores>
<book id="parent">
<name="it1"/>
<name="it2"/>
</book>
<book id="child">
<name="it3"/>
</book>
</bookstores>