Dos code to remove duplicates

There’s probably a much easier way to do this, but this code removes duplicate lines from a file. Only the first occurrence of a line is kept, but the order of the first occurrences is maintained

for /F %I in (cfc_scorers.txt) do (findstr %I cfc_order_of_scoring.txt
if ERRORLEVEL 1 echo %I >> cfc_order_of_scoring.txt
)

So if cfc_scorers.txt is:

Anelka
Malouda
Boswinga
Lampard
Mata
Mata
Terry
Sturridge
Torres
Torres
Ramires
Ramires
Lampard
Sturridge
Lampard
Sturridge

Then the created file will be:

Anelka
Malouda
Boswinga
Lampard
Mata
Terry
Sturridge
Torres
Ramires
Advertisements