Compare two lists of elements, remove same and recycle for next run
Posted: 22 Sep 2021 12:23
Hi everyone,
this is a small contribution for the community to thank all the time I have been helped, I hope it will be useful to someone, and I hope don't made any mistakes lol
Purpose: compare two list of elements to remove all duplicate in each list, also item remain will be used for next compare with a new file
this is a small contribution for the community to thank all the time I have been helped, I hope it will be useful to someone, and I hope don't made any mistakes lol
Purpose: compare two list of elements to remove all duplicate in each list, also item remain will be used for next compare with a new file
Code: Select all
@echo off
setlocal EnableDelayedExpansion
if exist %1 type %1 >> Recycle_%1
sort.exe -u Recycle_%1 > %1 && del /q Recycle_%1
if exist %2 type %2 >> Recycle_%2
sort.exe -u Recycle_%2 > %2 && del /q Recycle_%2
for /f %%i in ("%1") do set size_%1=%%~zi
for /f %%i in ("%2") do set size_%2=%%~zi
if %size_%2% equ 0 (
type %1 > Recycle_%1
) else if %size_%1% neq 0 (
findstr /livg:%1 %2 > Recycle_%2
) else (type %1 > Recycle_%1)
if %size_%1% equ 0 (
type %2 > Recycle_%2
) else if %size_%2% neq 0 (
findstr /livg:%2 %1 > Recycle_%1
) else (type %2 > Recycle_%2)
del /q %1
del /q %2