Reputation: 127
I have two .properties files as follows
first.properties second.properties
----------------- ---------------------
firstname=firstvalue fourthname=fourthvalue
secondname=secondvalue sixthname=sixthvalue
thirdname=thirdvalue nineththname=ninethvalue
fourthname=fourthvalue tenthname=tenthvalue
fifthname=fifthvalue
sixthname=sixthvalue
seventhname=seventhvalue
i want to compare two files and need to remove common name-value pair from first.properties. The output file should be as
third.properties.
------------------
firstname=firstvalue
secondname=secondvalue
thirdname=thirdvalue
fifthname=fifthvalue
seventhname=seventhvalue
i used the following code,but it is giving Cartesian product scenario.can you please help me out to achieve the above.
for /F "tokens=1,2 delims==" %%E in (first.properties) do (
for /F "tokens=1,2 delims==" %%G in (second.properties) do (
if "%%E" NEQ "%%G" echo %%E=%%F>>!HOME!\Properties\third.properties
)
)
Upvotes: 0
Views: 73
Reputation: 41224
Be very careful that you explain your task fully. With the new information, this works here.
@echo off
pushd "d:\folder"
copy /y "first.properties" "third.properties" >nul
for /f "delims==" %%a in (' type "second.properties" ') do (
find /v /i "%%a=" <"third.properties" > "third.properties.tmp"
move /y "third.properties.tmp" "third.properties" >nul
)
Upvotes: 1
Reputation: 37569
try this:
findstr /vg:second.properties first.properties>third.properties
Upvotes: 0